xarray.CFTimeIndex.shift

CFTimeIndex.shift(n, freq)

Shift the CFTimeIndex a multiple of the given frequency.

See the documentation for cftime_range() for a complete listing of valid frequency strings.

Parameters:
  • n (int) – Periods to shift by
  • freq (str or datetime.timedelta) – A frequency string or datetime.timedelta object to shift by
Returns:

Return type:

CFTimeIndex

See also

pandas.DatetimeIndex.shift()

Examples

>>> index = xr.cftime_range("2000", periods=1, freq="M")
>>> index
CFTimeIndex([2000-01-31 00:00:00], dtype='object')
>>> index.shift(1, "M")
CFTimeIndex([2000-02-29 00:00:00], dtype='object')