-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #3141 add cumsum to DatasetGroupBy #3417
Conversation
expected = xr.Dataset( | ||
{ | ||
"foo": (("x",), [7, 10, 1, 2, 1, 2, 3]), | ||
"group_id": (("x",), [0, 0, 1, 1, 2, 2, 2]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why group_id
becomes a data variable rather than a coord?
Here's the equivalent with sum
:
In [6]: ds.groupby("group_id").sum()
Out[6]:
<xarray.Dataset>
Dimensions: (group_id: 3)
Coordinates:
* group_id (group_id) int64 0 1 2
Data variables:
foo (group_id) int64 10 2 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group_id
is removed from coords in this line
Line 363 in 6b70107
coords.discard(name) |
If we comment this line and run our example again, group_id appears in coords after cumsum. I need some help to understand what this line does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could look more.
Does anyone who have more experience with this code know what's happening?
Any progress on this one? I would like to use this functionality. I have a workaround for right now, but it would be nice to do it "correctly" |
I'm very sorry this didn't get attention — it was a good PR and it's bad of us to drop something from a first-time contributor. It was surprising that it promoted the The good news is that we simplified how methods are supplied to the |
Aren't we soon going to let flox handle this once #5734 is merged? numpy_groupies supports cumsum at least so it might be possible to support it in flox as well. |
Ah, great, if flox supports |
It doesn't at the moment. Writing the dask version will be fun :). We can always add |
I opened #6525 preserving commit authorship. Does that look right to everyone? I could force-push here but was afraid of losing the author info. That PR doesn't actually work, it's not clear to me why. EDIT: OK it works now, but we have the same error about losing an index |
Thanks a lot @dcherian ! |
black . && mypy . && flake8