Python exercise · about 5 minutes · free
Missing Values
Blank incomes break averages and models. Count them, then decide what to do. Never ignore them silently.
s.isna().sum() counts missing values. s.fillna(value) fills them; the median is a common, outlier-resistant choice. Always record how many you filled.
Your quest: Set
missing to the number of missing incomes, then fill them with the median of the known incomes.Try it now Runs in your browser. No sign-in needed. Ctrl+Enter to run.
Hint
missing = df["income"].isna().sum(); df["income"] = df["income"].fillna(df["income"].median())Output appears here.