-
-
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
Dataset.groupby() doesn't preserve variables order #1042
Comments
This is probably a bug. Usually, we're pretty careful to always use |
Thanks @shoyer , here's a mwe: import xarray as xr
import numpy as np
ds = xr.Dataset()
for vn in ['a', 'b', 'c']:
ds[vn] = xr.DataArray(np.arange(10), dims=['t'])
ds.groupby('t').mean()
<xarray.Dataset>
Dimensions: (t: 10)
Coordinates:
* t (t) int64 0 1 2 3 4 5 6 7 8 9
Data variables:
a (t) float64 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
c (t) float64 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
b (t) float64 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 |
@shoyer I'd be happy to provide a fix if you want. Could you give a short pointer as to where the logic is implemented? |
So the tricky part here is that it's not obvious what is breaking here. One clue is that reducing doesn't seem to be necessary -- I can reproduce this just with applying an identity transform:
Actually, it looks like it's probably a
|
Closed via #1049 |
I am seeing something similar, but maybe this is another issue (I'm on 0.10.0rc2)? I do get a sorted string coordinate after a groupby... My scenario is, that I have a dataset with a coord like this:
Then I create a new coordinate that I use to aggregate:
Then in the end I have:
Am I missing something? |
Is it intentional? I think it is rather undesirable, but maybe there is some reason for this.
The text was updated successfully, but these errors were encountered: