Python Practice › Pandas Programs › Program 84

Columns with missing values

EasyPandas Programs · 84 of 95

Write a pandas program to find the columns with at least one missing value.

Advertisement
Output
['name', 'age']

Approach

  1. isna().any().

Solution

Python
import numpy as npimport pandas as pddf = pd.DataFrame({"sr": [1, 2, 3, 4], "name": ["Alex", np.nan, "Peter", "Klaus"], "age": [30, np.nan, 29, np.nan]})print(df.columns[df.isna().any()].tolist())
Output
['name', 'age']
Advertisement

Learn the concept

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

More pandas programs

← All 95 Pandas Programs