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

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

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