Columns with missing values
Write a pandas program to find the columns with at least one missing value.
['name', 'age']
Approach
isna().any().
Solution
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())['name', 'age']
Learn the concept
New to this topic? Read the lesson, then come back.