0 votes
1 view
in Python by (19.9k points)

In Python Pandas, what's the best way to check whether a DataFrame has one (or more) NaN values?

I know about the function pd.isnan, but this returns a DataFrame of booleans for each element. This post right here doesn't exactly answer my question either.

1 Answer

0 votes
by (50k points)

To check whether any value is NaN or not in a Pandas DataFrame in a specific column you can use the isnull() method.

nan_rows = df[df['name column'].isnull()]

You can also use the df.isnull().values.any()to check for NaN value in a Pandas DataFrame

...