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/2481#issuecomment-699599921,https://api.github.com/repos/pydata/xarray/issues/2481,699599921,MDEyOklzc3VlQ29tbWVudDY5OTU5OTkyMQ==,26384082,2020-09-27T07:50:54Z,2020-09-27T07:50:54Z,NONE,"In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,369639339 https://github.com/pydata/xarray/issues/2481#issuecomment-429856032,https://api.github.com/repos/pydata/xarray/issues/2481,429856032,MDEyOklzc3VlQ29tbWVudDQyOTg1NjAzMg==,81219,2018-10-15T13:39:25Z,2018-10-15T13:39:25Z,CONTRIBUTOR,"Got it, thanks for the workaround ! ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,369639339 https://github.com/pydata/xarray/issues/2481#issuecomment-429497014,https://api.github.com/repos/pydata/xarray/issues/2481,429497014,MDEyOklzc3VlQ29tbWVudDQyOTQ5NzAxNA==,6628425,2018-10-13T00:42:35Z,2018-10-13T00:42:35Z,MEMBER,"I think this would be a fair amount of work to implement :), but in principle it would be a natural step forward in the pattern we have been following in porting time series functionality from pandas for use with calendars supported by `cftime`. In the short term, at least for the use-case you describe above, I think a potentially simpler option would be to use a call to `CFTimeIndex.shift`; based on your example I'll illustrate with the DatetimeIndex version, since `resample` doesn't exist yet for a CFTimeIndex: ``` In [1]: import xarray as xr; import pandas as pd In [2]: times = pd.date_range('2000', periods=361) In [3]: da = xr.DataArray(range(361), [('time', times)]) In [4]: monthly_count = da.resample(time='M').count() In [5]: end_time = monthly_count.indexes['time'] In [6]: start_time = end_time.shift(-1, 'M') In [7]: expected_days_in_group = end_time - start_time In [8]: expected_days_in_group Out[8]: TimedeltaIndex(['31 days', '29 days', '31 days', '30 days', '31 days', '30 days', '31 days', '31 days', '30 days', '31 days', '30 days', '31 days'], dtype='timedelta64[ns]', name=u'time', freq=None) ``` Note that currently subtracting one CFTimeIndex from another (analogous to `end_time - start_time` in the example above) raises an error (I think it should also return a TimedeltaIndex), but that's probably a straightforward fix (I'll create a separate issue): ``` In [8]: a = xr.cftime_range('2000', periods=12, freq='M') In [9]: b = a.shift(-1, 'M') In [10]: a - b --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 a - b /Users/spencerclark/xarray-dev/xarray/xarray/coding/cftimeindex.pyc in __sub__(self, other) 365 366 def __sub__(self, other): --> 367 return CFTimeIndex(np.array(self) - other) 368 369 TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'CFTimeIndex' ``` ----- As a side note, support even for standard PeriodIndexes in xarray needs some work -- see the following existing open issues: #1270, #1565. Serialization to netCDF files would also be nice to support (but I don't see an existing issue for that). I'm sure work to fix these issues would also be appreciated!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,369639339