Dataset.roll(shifts=None, roll_coords=None, **shifts_kwargs)[source]

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

Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with numpy.roll().

  • shifts (dict, optional) – A dict with keys matching dimensions and values given by integers to rotate each of the given dimensions. Positive offsets roll to the right; negative offsets roll to the left.

  • roll_coords (bool) – Indicates whether to roll the coordinates by the offset The current default of roll_coords (None, equivalent to True) is deprecated and will change to False in a future version. Explicitly pass roll_coords to silence the warning.

  • **shifts_kwargs ({dim: offset, ...}, optional) – The keyword arguments form of shifts. One of shifts or shifts_kwargs must be provided.


rolled (Dataset) – Dataset with the same coordinates and attributes but rolled variables.

See also



>>> ds = xr.Dataset({"foo": ("x", list("abcde"))})
>>> ds.roll(x=2)
Dimensions:  (x: 5)
Dimensions without coordinates: x
Data variables:
    foo      (x) <U1 'd' 'e' 'a' 'b' 'c'