home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 218756391

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-218756391 https://api.github.com/repos/pydata/xarray/issues/818 218756391 MDEyOklzc3VlQ29tbWVudDIxODc1NjM5MQ== 1197350 2016-05-12T13:26:58Z 2016-05-12T13:26:58Z MEMBER

@jhamman: My latest commit followed @shoyer's suggestion to fix the "non-monotonic" error.

I successfully loaded your data and took a zonal average in 10-degree bins with the following code:

``` python

ds = xr.open_dataset('sample_for_xarray_multigroupby.nc', decode_times=False) lat_bins = np.arange(20,90,10) t_mean = ds.sample_tsurf.groupby('TLAT', bins=lat_bins).mean() t_mean <xarray.DataArray 'sample_tsurf' (TLAT: 6)> array([ 27.05354874, 24.00267499, 15.74423768, 11.16990181, 6.45922212, 0.48820518]) Coordinates: time float64 7.226e+05 z_t float64 250.0 * TLAT (TLAT) object '(20, 30]' '(30, 40]' '(40, 50]' '(50, 60]' ... ```

The only big remaining issue is the values of the new coordinate. Currently it is just using the labels output by pd.cut, which are strings. This means if I try t_mean.plot(), I get TypeError: Plotting requires coordinates to be numeric or dates.

We could either allow the user to specify labels by adding a labels keyword to groupby, or we could infer the labels automatically, e.g. by taking the centered mean of the bins:

python bin_labels = 0.5*(lat_bins[1:] + lat_bins[:-1]

Please weigh in if you have an opinion about that.

{
    "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 2.022ms · About: xarray-datasette