xarray.CFTimeIndex.shift

xarray.CFTimeIndex.shift#

CFTimeIndex.shift(n, freq)[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:
  • n (int, float if freq of days or below) – Periods to shift by

  • freq (str or datetime.timedelta) – A frequency string or datetime.timedelta object to shift by

Returns:

CFTimeIndex

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)