Python Practice › Pandas Programs › Program 88
Drop rows that are entirely missing
Write a pandas program to drop rows where all values are missing.
Output
name age 0 Alex 30.0 2 Peter NaN
Approach
dropna(how="all").
Solution
import numpy as npimport pandas as pddf = pd.DataFrame({"name": ["Alex", np.nan, "Peter"], "age": [30, np.nan, np.nan]})print(df.dropna(how="all"))Output
name age 0 Alex 30.0 2 Peter NaN
Learn the concept
New to this topic? Read the lesson, then come back.