# xarray.DataArray.shift

#### DataArray.shift(shifts=None, fill_value=<NA>, \*\*shifts_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L5164-L5212)

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

Only the data is 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` to [`int`](https://docs.python.org/3/builtins/functions.html#int) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – 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), *optional*) – Value to use for newly missing values
  * **\*\*shifts_kwargs** – The keyword arguments form of `shifts`.
    One of shifts or shifts_kwargs must be provided.
* **Returns:**
  **shifted** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – DataArray with the same coordinates and attributes but shifted
  data.

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

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('7148db04-ffa4-42b8-beaa-abe82add3be6','8b62c91c-0579-4842-a948-48c835b70e6f','1d283596-cac6-4333-a4b7-0019e2dafaa8','../lite/tree/../notebooks/index.html?path=626c23fe_dc26_4c9b_939d_70f949105fcf.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> arr = xr.DataArray([5, 6, 7], dims="x")
>>> arr.shift(x=1)
<xarray.DataArray (x: 3)> Size: 24B
array([nan,  5.,  6.])
Dimensions without coordinates: x
```

<div id="1d283596-cac6-4333-a4b7-0019e2dafaa8" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('7148db04-ffa4-42b8-beaa-abe82add3be6','1d283596-cac6-4333-a4b7-0019e2dafaa8')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('7148db04-ffa4-42b8-beaa-abe82add3be6','1d283596-cac6-4333-a4b7-0019e2dafaa8')">Open In Tab</button></div><div id="8b62c91c-0579-4842-a948-48c835b70e6f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
