You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding a TimedeltaIndex to a CFTimeIndex would also make sense:
In [1]: import xarray as xr; import pandas as pd
In [2]: a = xr.cftime_range('2000', periods=5)
In [3]: deltas = pd.TimedeltaIndex([pd.Timedelta(days=1) for _ in range(5)])
In [4]: a + deltas
Out[4]:
CFTimeIndex([2000-01-02 00:00:00, 2000-01-03 00:00:00, 2000-01-04 00:00:00,
2000-01-05 00:00:00, 2000-01-06 00:00:00],
dtype='object')
In [5]: deltas + a
Out[5]:
CFTimeIndex([2000-01-02 00:00:00, 2000-01-03 00:00:00, 2000-01-04 00:00:00,
2000-01-05 00:00:00, 2000-01-06 00:00:00],
dtype='object')
So would subtracting a TimedeltaIndex from a CFTimeIndex:
In [6]: a - deltas
Out[6]:
CFTimeIndex([1999-12-31 00:00:00, 2000-01-01 00:00:00, 2000-01-02 00:00:00,
2000-01-03 00:00:00, 2000-01-04 00:00:00],
dtype='object')
spencerkclark
changed the title
Subtracting a CFTimeIndex from a CFTimeIndex should return a TimedeltaIndex
Enable add/sub operations involving a CFTimeIndex and a TimedeltaIndex
Oct 13, 2018
Problem description
Subtracting one DatetimeIndex from another produces a TimedeltaIndex:
This should also be straightforward to enable for CFTimeIndexes and would be useful, for example, in the problem described in #2481 (comment).
Expected Output
The text was updated successfully, but these errors were encountered: