head
- UnitsAwareDataArray.head(indexers: Mapping[Any, int] | int | None = None, **indexers_kwargs: Any) Self
Return a new DataArray whose data is given by the the first n values along the specified dimension(s). Default n = 5
See also
Dataset.head
,DataArray.tail
,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.head(x=1) <xarray.DataArray (x: 1, y: 5)> Size: 40B array([[0, 1, 2, 3, 4]]) Dimensions without coordinates: x, y
>>> da.head({"x": 2, "y": 2}) <xarray.DataArray (x: 2, y: 2)> Size: 32B array([[0, 1], [5, 6]]) Dimensions without coordinates: x, y