O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determining NaN values in pandas objects

The NaN values in a DataFrame object can be identified using the .isnull() method. Any True value means that the item at that location is a NaN value:

We can use the fact that the .sum() method treats True as 1 and False as 0 to determine the number of NaN values in a DataFrame object:

Applying .sum() to the resulting series gives the total number of NaN values in the original DataFrame object:

This is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required