xarray.CFTimeIndex.shift#
- CFTimeIndex.shift(periods, freq=None)[source]#
Shift the CFTimeIndex a multiple of the given frequency.
See the documentation for
cftime_range()
for a complete listing of valid frequency strings.- Parameters
periods (
int
,float if freq
ofdays
orbelow
) – Periods to shift byfreq (
str
,datetime.timedelta
orBaseCFTimeOffset
) – A frequency string or datetime.timedelta object to shift by
- Returns
See also
pandas.DatetimeIndex.shift
Examples
>>> index = xr.cftime_range("2000", periods=1, freq="ME") >>> index CFTimeIndex([2000-01-31 00:00:00], dtype='object', length=1, calendar='standard', freq=None) >>> index.shift(1, "ME") CFTimeIndex([2000-02-29 00:00:00], dtype='object', length=1, calendar='standard', freq=None) >>> index.shift(1.5, "D") CFTimeIndex([2000-02-01 12:00:00], dtype='object', length=1, calendar='standard', freq=None)