# xarray.Dataset.shift

#### Dataset.shift(shifts=None, fill_value=<NA>, \*\*shifts_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L8106-L8175)

Shift this dataset by an offset along one or more dimensions.

Only data variables are moved; coordinates stay in place. This is
consistent with the behavior of `shift` in pandas.

Values shifted from beyond array bounds will appear at one end of
each dimension, which are filled according to fill_value. For periodic
offsets instead see roll.

* **Parameters:**
  * **shifts** ([mapping](https://docs.python.org/3/glossary.html#term-mapping) of [hashable](../user-guide/terminology.html.md#term-name) to [`int`](https://docs.python.org/3/builtins/functions.html#int)) – Integer offset to shift along each of the given dimensions.
    Positive offsets shift to the right; negative offsets shift to the
    left.
  * **fill_value** ([scalar](../user-guide/terminology.html.md#term-scalar) or [dict-like](https://docs.python.org/3/glossary.html#term-mapping), *optional*) – Value to use for newly missing values. If a dict-like, maps
    variable names (including coordinates) to fill values.
  * **\*\*shifts_kwargs** – The keyword arguments form of `shifts`.
    One of shifts or shifts_kwargs must be provided.
* **Returns:**
  **shifted** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – Dataset with the same coordinates and attributes but shifted data
  variables.

#### SEE ALSO
[`roll`](xarray.Dataset.roll.html.md#xarray.Dataset.roll)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('64f81e2a-339d-4db8-b8cc-04de52c9881b','0bb9a0a5-688f-4599-b988-cdfd58c59288','74429c2c-1f0a-4a0f-98fc-40dd541101c6','../lite/tree/../notebooks/index.html?path=cc59f498_7328_47ef_ba78_16fe07448083.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> ds = xr.Dataset({"foo": ("x", list("abcde"))})
>>> ds.shift(x=2)
<xarray.Dataset> Size: 40B
Dimensions:  (x: 5)
Dimensions without coordinates: x
Data variables:
    foo      (x) object 40B nan nan 'a' 'b' 'c'
```

<div id="74429c2c-1f0a-4a0f-98fc-40dd541101c6" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('64f81e2a-339d-4db8-b8cc-04de52c9881b','74429c2c-1f0a-4a0f-98fc-40dd541101c6')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('64f81e2a-339d-4db8-b8cc-04de52c9881b','74429c2c-1f0a-4a0f-98fc-40dd541101c6')">Open In Tab</button></div><div id="0bb9a0a5-688f-4599-b988-cdfd58c59288" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
