bundles / numpy 2.4.3 / numpy / ma / core / count
function
numpy.ma.core:count
source: /numpy/ma/core.py :7063
Summary
Count the non-masked elements of the array along the given axis.
Parameters
axis: None or int or tuple of ints, optionalAxis or axes along which the count is performed. The default, None, performs the count over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis. If this is a tuple of ints, the count is performed on multiple axes, instead of a single axis or all the axes as before.
keepdims: bool, optionalIf this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the array.
Returns
result: ndarray or scalarAn array with the same shape as the input array, with the specified axis removed. If the array is a 0-d array, or if axis is None, a scalar is returned.
Examples
import numpy.ma as ma a = ma.arange(6).reshape((2, 3)) a[1, :] = ma.masked a a.count()When the `axis` keyword is specified an array of appropriate size is returned.
a.count(axis=0) a.count(axis=1)
See also
- ma.count_masked
Count masked elements in array or along a given axis.
Aliases
-
numpy.ma.count