Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k 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 (106k 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

Learn python with the help of this python training. 

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

29.3k questions

30.6k answers

501 comments

104k users

Browse Categories

...