xdas.count_nonzero#

xdas.count_nonzero(da, dim=None, **kwargs)[source]#

Count the number of non-zero values along the specified dimension.

Parameters:
  • da (DataArray) – Input data.

  • dim (str, optional) – Dimension along which the count is computed. If None, the count of non-zero values in the flattened array is returned. Default is None.

  • **kwargs – Additional keyword arguments passed to the NumPy function.

Returns:

Number of non-zero values along the specified dimension. If dim is None, a single integer value is returned; if dim is specified, the result has the same shape as the input data.

Return type:

int or DataArray