Chapter 2 · Section 3 practice

Missing Data and Cleaning Decisions

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. Count missing sales

Warm-up. Print the number of missing Sales entries.

Write your answer, then run it.

2. Keep a recorded zero

Warm-up. Print Order labels for observed Sales equal to zero.

Write your answer, then run it.

3. Missing counts by column

Warm-up. Print the missing count for every column.

Write your answer, then run it.

4. Drop incomplete records

Build your skills. Drop rows with any missing entry and print retained Order labels.

Write your answer, then run it.

5. Check only Sales

Build your skills. Drop rows only when Sales is missing. Print retained Order labels.

Write your answer, then run it.

6. Mean denominator

Build your skills. Print the row count, observed Sales count, and Sales mean rounded to two decimals.

Write your answer, then run it.

7. Median fill in a copy

Build your skills. Copy df and fill missing Sales with its observed median. Print the filled list and show that df still has one missing Sale.

Write your answer, then run it.

8. Column deletion

Challenge. Drop columns containing any missing entry and print the remaining column names.

Write your answer, then run it.

9. Carry a valid fee forward

Challenge. Forward-fill these recorded fees and print the resulting list. Explain why the first entry stays missing.

Write your answer, then run it.

10. Observed values and a threshold

Challenge. Select only non-missing values <= 3 and print them as a list.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.