原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.MaskedArray.count.html
校对:(虚位以待)
MaskedArray.
count
(axis=None, keepdims=<class numpy._globals._NoValue>)[source]沿给定轴计算数组的非屏蔽元素。
参数: | axis:无或int或tuple ints,可选
keepdims:bool,可选
|
---|---|
返回: | result:ndarray或scalar
|
也可以看看
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
当指定axis关键字时,返回适当大小的数组。
>>> a.count(axis=0)
array([1, 1, 1])
>>> a.count(axis=1)
array([3, 0])