issue_comments: 254676127
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/issues/158#issuecomment-254676127 | https://api.github.com/repos/pydata/xarray/issues/158 | 254676127 | MDEyOklzc3VlQ29tbWVudDI1NDY3NjEyNw== | 12852539 | 2016-10-19T00:18:53Z | 2016-10-19T00:25:38Z | NONE | Why won't this be fixed? I think some clarification in the documentation would be useful. Currently they say:
However, pandas supports grouping by a function or by any array (e.g. it can be a pandas object or a numpy array). The xarray API is narrower than pandas, and has an undocumented requirement of a named DataArray (contrasting xarray behaviour of creating default names like "dim_0" elsewhere). ``` python import numpy as np data = np.arange(10) + 10 # test data f = lambda x: np.floor_divide(x,2) # grouping key import pandas as pd for key in f, f(data), pd.Series(f(data)): print pd.Series(data).groupby(key).mean().values print pd.DataFrame({'thing':data}).groupby(key).mean().thing.values these pandas examples are all equivalentimport xarray as xr
da = xr.DataArray(data)
key = xr.DataArray(f(data))
key2 = xr.DataArray(f(data), name='key')
print da.groupby(key2).mean().values # this line works
print da.groupby(key).mean().values # broken: ValueError: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
35682274 |