# xarray.CFTimeIndex.shift

#### CFTimeIndex.shift(periods, freq=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/cftimeindex.py#L475-L531)

Shift the CFTimeIndex a multiple of the given frequency.

See the documentation for [`date_range()`](xarray.date_range.html.md#xarray.date_range) for a
complete listing of valid frequency strings.

* **Parameters:**
  * **periods** ([`int`](https://docs.python.org/3/builtins/functions.html#int), `float if freq` of `days` or `below`) – Periods to shift by
  * **freq** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta) or `BaseCFTimeOffset`) – A frequency string or datetime.timedelta object to shift by
* **Returns:**
  [`CFTimeIndex`](xarray.CFTimeIndex.html.md#xarray.CFTimeIndex)

#### SEE ALSO
`pandas.DatetimeIndex.shift`

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('17c48905-dc79-4490-95c5-ee772f56bd27','cf1f51d5-5ac0-488b-a1a0-0f9ca4f0220f','434e1d96-9f28-4641-bedd-e7f155fe0827','../lite/tree/../notebooks/index.html?path=986922f0_f7e7_4ad1_8da8_1f9cc6441afb.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> index = xr.date_range("2000", periods=1, freq="ME", use_cftime=True)
>>> 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, "24h")
CFTimeIndex([2000-02-01 12:00:00],
            dtype='object', length=1, calendar='standard', freq=None)
```

<div id="434e1d96-9f28-4641-bedd-e7f155fe0827" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('17c48905-dc79-4490-95c5-ee772f56bd27','434e1d96-9f28-4641-bedd-e7f155fe0827')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('17c48905-dc79-4490-95c5-ee772f56bd27','434e1d96-9f28-4641-bedd-e7f155fe0827')">Open In Tab</button></div><div id="cf1f51d5-5ac0-488b-a1a0-0f9ca4f0220f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
