0 votes
1 view
in Python by (47.7k 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 (107k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...