Reputation: 21971
Is there an easy way to check if numpy array is masked or not?
Currently, I do the following to check if marr
is masked or not:
try:
arr = marr.data
except:
arr = marr
Upvotes: 6
Views: 1964
Reputation: 16189
You can use the python function isinstance
to check if an object is an instance of a class.
>>> isinstance(np.ma.array(np.arange(10)),np.ma.MaskedArray)
True
>>> isinstance(np.arange(10),np.ma.MaskedArray)
False
Upvotes: 9