Python Practice › Pandas Programs › Program 85
Missing values per column
Write a pandas program to count the missing values in each column.
Output
name 1 age 2 dtype: int64
Approach
isna().sum().
Solution
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
Learn the concept
New to this topic? Read the lesson, then come back.