cf.Data.count

Data.count()[source]

Count the non-masked elements of the data.

See also

count_masked

Returns

int

Examples:

>>> d = cf.Data(numpy.arange(24).reshape(3, 4))
>>> print(d.array)
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
>>> d.count()
12
>>> d[0, :] = cf.masked
>>> print(d.array)
[[-- -- -- --]
 [ 4  5  6  7]
 [ 8  9 10 11]]
>>> d.count()
8
>>> print(d.count(0).array)
[2 2 2 2]
>>> print(d.count(1).array)
[0 4 4]
>>> print(d.count((0, 1)))
8