To count the NaN values in a column in Python Pandas DataFrame, we call isna
and sum
.
For instance, we write
s = pd.Series([1,2,3, np.nan, np.nan])
count = s.isna().sum()
to create a series witth pd.Series
.
The we call isna
to return the isna
values in the series.
And then we call sum
to get the count of them.