I have an array
a = np.array([1,2,3,4,np.nan])
I would like to replace anything which is less than 1.5 by np.nan
, i.e. I would like
a = np.array([np.nan,2,3,4,np.nan])
how do I do that?
I did
a[a<1.5] = np.nan
I got the following run time warning error in IPython (Py3.4) RuntimeWarning: invalid value encountered in less
. Is this because my list had np.nan
? Is there anything I can do to prevent this?
Also is there a way doing this inline without assigning? Instead of doing
a[a<1.5]=np.nan
return a
I can just do
return a...
where that .... is something that need filling in.