Tsallaka zuwa abun ciki
Justice Tech School

Masked Arrays

Masked arrays ignore invalid entries in calculations.

Example
a = np.ma.masked_array([1, 2, -999, 4], mask=[0, 0, 1, 0])
print(a.mean(), a.sum())
print(a.filled(0))

Result

2.3333333333333335 7
[1 2 0 4]

Exercise

Hide invalid values.

np.ma.(data, mask)

Quiz Test

What does a mask hide?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.