xarray.DataArray.pr.count#
- DataArray.pr.count(dim: DimOrDimsT | None = None, *, reduce_to_dim: DimOrDimsT | None = None, keep_attrs: bool = True, **kwargs) DataArray #
Reduce this array by counting along some dimension(s).
By default, works like
xarray.DataArray.count()
, but with some additional features:Dimension aliases can be used instead of full dimension names everywhere.
Instead of specifying the dimension(s) to reduce via
dim
, you can specify the dimensions that the result should have viareduce_to_dim
. Then,count
will be applied along all other dimensions.
- Parameters:
- dim: str or list of str, optional
Dimension(s) over which to apply
count
. Only one ofdim
andreduce_to_dim
arguments can be supplied. If neither is supplied, then the count is calculated over all dimensions.- reduce_to_dim: str or list of str, optional
Dimension(s) of the result. Only one of
dim
andreduce_to_dim
arguments can be supplied. Supplyingreduce_to_dim="dim_1"
is therefore equivalent to givingdim=set(da.dims) - {"dim_1"}
, but more legible.- keep_attrs: bool, optional
Keep the attr metadata (default True).
- **kwargs: dict
Additional keyword arguments are passed directly to xarray’s da.count().
- Returns:
- counted: xr.DataArray
See also