BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: Missing Data

Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.

Module 2: Data Analytics

0/3 done
Exercises (0/3)
  • 1
    Drop Rows with Any Missing Value
    Context. A CSV came in with some missing values — keep only complete rows. Your task. Write complete_rows(df) that returns rows where no column has a NaN. Example. A row with NaN in any single column is dropped, even if all other columns are filled. Notes. No NaNs anywhere → all rows kept. Every row has at least one NaN → empty DataFrame.
    7 min· 10 XP
  • 2
    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.
    7 min· 10 XP
  • 3
    Count Missing Values per Column
    Context. Audit a dataset — how many NaNs in each column? Your task. Write nan_counts(df) that returns a Series indexed by column name, with the count of NaN values in each column. Example. A df with 2 NaN in age and 1 NaN in city → {age: 2, city: 1, name: 0}. Notes. Include columns with zero NaN. Empty df → Series with one zero per column.
    7 min· 10 XP