home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 207531654

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/pull/818#issuecomment-207531654 https://api.github.com/repos/pydata/xarray/issues/818 207531654 MDEyOklzc3VlQ29tbWVudDIwNzUzMTY1NA== 1197350 2016-04-08T17:39:10Z 2016-04-08T18:07:11Z MEMBER

I have tried adding a new keyword bins arg to groupby, which should accomplish what I want and more. (It will also work on regular one-dimensional groupby operations.)

The way it works is like this:

``` python

ar = xr.DataArray(np.arange(4), dims='dim_0') ar <xarray.DataArray (dim_0: 4)> array([0, 1, 2, 3]) Coordinates: * dim_0 (dim_0) int64 0 1 2 3 ar.groupby('dim_0', bins=[2,4]).sum() <xarray.DataArray (dim_0: 2)> array([1, 5]) Coordinates: * dim_0 (dim_0) int64 2 4 ```

The only problem is that it seems to overwrite the original dimension of the array! After calling groupby

``` python

ar <xarray.DataArray (dim_0: 4)> array([0, 1, 2, 3]) Coordinates: * dim_0 (dim_0) int64 2 4 ```

I think that resample overcomes this issue by renaming the dimension: https://github.com/pydata/xarray/blob/master/xarray/core/common.py#L437

I guess something similar should be possible here...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  146182176
Powered by Datasette · Queries took 1.448ms · About: xarray-datasette