BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/Missing Data3/3
Exercise·7 min·10 XP

Fill Missing Values in a Column

Context. A survey has some blank age entries; fill them with a default so downstream math doesn't break.

Your task. Write fill_missing_ages(df, default) that returns a new DataFrame where NaN values in the age column are replaced with default. Other columns are untouched.

Example. age [30, NaN, 25, NaN], default=0 → [30, 0, 25, 0].

Notes. Only the age column is modified. df with no NaN in age → unchanged.

Previous
Drop Rows with Any Missing Value
Next
Count Missing Values per Column