MaskedArray.count(axis=None, keepdims=)
[source]
Count the non-masked elements of the array along the given axis.
Parameters: |
axis : None or int or tuple of ints, optional Axis or axes along which the count is performed. The default ( New in version 1.10.0. 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, optional If 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 scalar An array with the same shape as the input array, with the specified axis removed. If the array is a 0-d array, or if |
See also
count_masked
>>> import numpy.ma as ma >>> a = ma.arange(6).reshape((2, 3)) >>> a[1, :] = ma.masked >>> a masked_array(data = [[0 1 2] [-- -- --]], mask = [[False False False] [ True True True]], fill_value = 999999) >>> a.count() 3
When the axis
keyword is specified an array of appropriate size is returned.
>>> a.count(axis=0) array([1, 1, 1]) >>> a.count(axis=1) array([3, 0])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.ma.MaskedArray.count.html