Pandas - Dataframe.apply(lambad X: X Is Np.nan) Does Not Work
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 i
Solution 1:
First things first. To get what you want:
df.A.isnull()
Secondly, np.nan
is not comparable. By design np.nan == np.nan
is False.
To get around this, pandas and numpy have specific functions to test if it is null. You could:
df.A.apply(pd.isnull)
But that is the same thing as:
df.A.isnull()
That I mentioned above.
Post a Comment for "Pandas - Dataframe.apply(lambad X: X Is Np.nan) Does Not Work"