Missing values count

Here, we'll look at how to use the DataFrame's isnull() and sum() methods to count NaN or missing entries in a Pandas DataFrame.

Dataframe.isnull() method:

To count the number of missing values in each column of a pandas DataFrame, we can use the isnull() method to create a boolean mask indicating which values are missing.

Dataframe.sum() method:

The sum() method is used to count the number of True values in each column.

Let us first load the libraries needed.
  • pandas
  • numpy
  1. Make a pandas dataframe first.

  2. Total the NaN values in each column of the DataFrame.

    This shows that column Name has 2 missing value, column Age has 3 missing values, column Place has 2 and column College has 3 missing values.
  3. Total the NaNs in the DataFrame.

2 Likes