issue_comments: 390973986
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/1270#issuecomment-390973986 | https://api.github.com/repos/pydata/xarray/issues/1270 | 390973986 | MDEyOklzc3VlQ29tbWVudDM5MDk3Mzk4Ng== | 6628425 | 2018-05-22T12:36:35Z | 2018-05-22T12:36:35Z | MEMBER |
@lvankampenhout I agree that it would be nice if xarray had better support for PeriodIndexes. Do you happen to be using a PeriodIndex because of pandas Timestamp-limitations? Despite the fact that generalized resample has not been implemented yet, I recommend you try using the new CFTimeIndex. As it turns out, for some one-off cases (like this one) resample is not too difficult to mimic using xr.set_options(enable_cftimeindex=True) Set up some example data indexed by cftime.DatetimeProlepticGregorian objectsdates = [datetime(year, month, 1) for year, month in product(range(2, 5), range(1, 13))] da = xr.DataArray(np.arange(len(dates)), coords=[dates], dims=['time']) Mimic resampling with the AS-JUN anchored offsetyears = da.time.dt.year - (da.time.dt.month < 6)
da['AS-JUN'] = xr.DataArray([datetime(year, 6, 1) for year in years], coords=da.time.coords)
resampled = da.groupby('AS-JUN').mean('time').rename({'AS-JUN': 'time'})
|
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
207862981 |