tail

UnitsAwareDataArray.tail(indexers: Mapping[Any, int] | int | None = None, **indexers_kwargs: Any) Self

Return a new DataArray whose data is given by the the last n values along the specified dimension(s). Default n = 5

See also

Dataset.tail, DataArray.head, DataArray.thin

Examples

>>> da = xr.DataArray(
...     np.arange(25).reshape(5, 5),
...     dims=("x", "y"),
... )
>>> da
<xarray.DataArray (x: 5, y: 5)> Size: 200B
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])
Dimensions without coordinates: x, y
>>> da.tail(y=1)
<xarray.DataArray (x: 5, y: 1)> Size: 40B
array([[ 4],
       [ 9],
       [14],
       [19],
       [24]])
Dimensions without coordinates: x, y
>>> da.tail({"x": 2, "y": 2})
<xarray.DataArray (x: 2, y: 2)> Size: 32B
array([[18, 19],
       [23, 24]])
Dimensions without coordinates: x, y