Reputation: 25999
I'm having a weird problem. I'm trying to block a dataframe from being processed when it has a NaN value for a specific column(in this case, "name").
print(df)
Assets_% Code Country Exchange Industry Name Region Sector
0 100.0 NaN NaN NaN NaN NaN NaN NaN
I've been trying different things but this row keeps sneaking past my filters:
if pd.notna(df['Name'].any):
#do something
elif df['Name'].isnull().any:
print("There is has a null value in name")
for some reason, the above data makes it through. What can I do? Is notna the right way to catch NaN values?
Upvotes: 1
Views: 45
Reputation: 79
Use .any() with parenthesis otherwise df['Name'].any will just return the method but not the boolean value.
Upvotes: 1