xarray.Dataset.shift

Dataset.shift(**shifts)

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.

Parameters:

**shifts : keyword arguments of the form {dim: offset}

Integer offset to shift along each of the given dimensions. Positive offsets shift to the right; negative offsets shift to the left.

Returns:

shifted : Dataset

Dataset with the same coordinates and attributes but shifted data variables.

See also

roll

Examples

>>> ds = xr.Dataset({'foo': ('x', list('abcde'))})
>>> ds.shift(x=2)
<xarray.Dataset>
Dimensions:  (x: 5)
Coordinates:
  * x        (x) int64 0 1 2 3 4
Data variables:
    foo      (x) object nan nan 'a' 'b' 'c'