Say you have the following list:
import numpy as np
mylist=[8.4468975,
8.52036,
9.3605785,
np.ma.core.MaskedConstant(),
np.ma.core.MaskedConstant()]
# [8.4468975, 8.52036, 9.3605785, masked, masked]
and you want to assign 0 to all values that are masked, and 1 to all the others. How can you properly do it?
I've tried this, but the result is an empty list:
mylist=[1 for i,v in enumerate(mylist) if type(mylist[i]) is float]
The result should be numerical (no True/False):
mylist=[1,1,1,0,0]
EDIT
The masked values that are present in my original list are of the type numpy.ma.core.MaskedConstant.