W3docs

How do I count the NaN values in a column in pandas DataFrame?

You can use the isna() function to create a boolean mask of the NaN values in a column, and then use the sum() function to count the number of True values in the mask.

You can use the isna() function to create a boolean mask of the NaN values in a column, and then use the sum() function to count the number of True values in the mask. Here's an example:

count the NaN values in a column in pandas DataFrame

python— editable, runs on the server
Info

Watch a video course: Python - The Practical Guide

You can also use df.isna().sum() to get the number of NaN values of all columns.