xarray.DataArray.shift¶
-
DataArray.
shift
(**shifts)¶ Shift this array by an offset along one or more dimensions.
Only the data is moved; coordinates stay in place. Values shifted from beyond array bounds are replaced by NaN. 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 : DataArray
DataArray with the same coordinates and attributes but shifted data.
See also
Examples
>>> arr = xr.DataArray([5, 6, 7], dims='x') >>> arr.shift(x=1) <xarray.DataArray (x: 3)> array([ nan, 5., 6.]) Coordinates: * x (x) int64 0 1 2