Python Practice › Pandas Programs › Program 85

Missing values per column

EasyPandas Programs · 85 of 95

Write a pandas program to count the missing values in each column.

Advertisement
Output
name    1
age     2
dtype: int64

Approach

  1. isna().sum().

Solution

Python
import numpy as npimport pandas as pddf = pd.DataFrame({"name": ["Alex", np.nan, "Peter", "Klaus"], "age": [30, np.nan, 29, np.nan]})print(df.isna().sum())
Output
name    1
age     2
dtype: int64
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs