# xarray.CFTimeIndex.shift

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

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('c1400ed7-4f07-41d1-b364-91335649eb05','7618dba8-3881-4b18-8c12-c0e9e1f155b6','f945e7d3-a718-434f-bbec-e5cf0b0ec10f','../lite/tree/../notebooks/index.html?path=d7062832_4e24_42f9_a5d2_8bfeac8dc798.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="f945e7d3-a718-434f-bbec-e5cf0b0ec10f" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('c1400ed7-4f07-41d1-b364-91335649eb05','f945e7d3-a718-434f-bbec-e5cf0b0ec10f')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('c1400ed7-4f07-41d1-b364-91335649eb05','f945e7d3-a718-434f-bbec-e5cf0b0ec10f')">Open In Tab</button></div><div id="7618dba8-3881-4b18-8c12-c0e9e1f155b6" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
