So basically a column in dataframe has Nan and float, I want to use apply to calculate the value in the column. If the value is nan, then return else, calculate.
But looks like x is np.nan in lambda does not give me the right answer. here is an example
In[6]: df = pd.DataFrame({'A':[np.nan,np.nan,np.nan,np.nan,np.nan,np.nan]})
In[7]: df.A.apply(lambda x: x is np.nan)
Out[7]:
0 False
1 False
2 False
3 False
4 False
5 False
Does anyone know the reason?