in my program i need to find out if a single value in my pandas.DataFrame is either a NaN or not? i figured:
print(df.loc[index, 'Column1'])
output:
nan
but this script works like a charm
nullV = None
print(nullV == None)
output:
True
not this though
print(df.loc[39, 'booking'] == None)
output:
False
CodePudding user response:
There is a difference between nan
and None
. A value of nan
still allows the column to be a 64-bit float dtype, instead of getting converted to the object
dtype.
To check if it is nan
, use:
df.loc[index, 'Column1'].isna()
CodePudding user response:
This should work:
import numpy as np
np.isnan(df.loc[39, 'booking'])