# 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('16150e77-b60e-4489-a679-6fa4a7b85206','25e4aa5d-eea2-4e1f-8d2c-9f2f308ba30c','3c483f1e-79e6-40c4-9b27-e0718b1d912c','../lite/tree/../notebooks/index.html?path=b89d2ac8_3d68_4faf_a05a_1a2c12768f4a.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="3c483f1e-79e6-40c4-9b27-e0718b1d912c" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('16150e77-b60e-4489-a679-6fa4a7b85206','3c483f1e-79e6-40c4-9b27-e0718b1d912c')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('16150e77-b60e-4489-a679-6fa4a7b85206','3c483f1e-79e6-40c4-9b27-e0718b1d912c')">Open In Tab</button></div><div id="25e4aa5d-eea2-4e1f-8d2c-9f2f308ba30c" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
