xarray.Dataset.roll

Dataset.roll(**shifts)

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

Unlike shift, roll rotates all variables, including coordinates. The direction of rotation is consistent with numpy.roll().

Parameters:

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

Integer offset to rotate each of the given dimensions. Positive offsets roll to the right; negative offsets roll to the left.

Returns:

rolled : Dataset

Dataset with the same coordinates and attributes but rolled variables.

See also

shift

Examples

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