If you have a df called train_data
like this:
train_data = pd.DataFrame( {'a':[1,2,3], 'b':[2,3,4]})
train_data.isnull().any()
tells you if in any column there is a nan
element:
a False
b False
dtype: bool
for this df: train_data = pd.DataFrame( {'a':[np.nan,2,3], 'b':[2,3,4]})
you will have:
a True
b False
dtype: bool
any()
is used to know if any of element of the column is np.nan
. For this df:
train_data = pd.DataFrame( {'a':[np.nan,5,np.nan], 'b':[2,3,4]})
train_data.isnull()
will have as output the boolean for each element:
a b
0 True False
1 False False
2 True False