cassionData Analysis

Exercise · Beginner

Read this export without breaking it

One CSV, six defects, and a read that has to survive all of them. Write the read_csv call and the four checks that prove it worked, then say what each defect would have cost.

Python45 min

Every defect in this exercise is in the file you already have. None of them raise. All of them change a number.

The file

muac-screening-artibonite-2024.v1.csv — 4,218 screening records from twelve communes in Artibonite, Haiti. Synthetic, and shaped like the real thing.

The task

Write a single read_csv call, plus whatever follows it, that produces a DataFrame in which:

  1. muac_mm contains no value that means “not measured”
  2. child_id and commune are text, not numbers
  3. screening_date is a datetime, parsed with an explicit format
  4. outcome is a categorical with a declared vocabulary
  5. oedema is a nullable boolean — True, False or missing, never a string
  6. the row count is asserted, so a truncated file fails rather than reporting a smaller caseload

Then write the four checks from lesson 3 — shape, dtypes, missing, first row — and run them.

What to hand in

A single Python file that runs top to bottom and prints:

  • the mean MUAC before and after the sentinel is declared
  • the number of records excluded by each of the six decisions above
  • the count of outcome values that fell outside your declared vocabulary
  • the count of oedema values your boolean map did not cover

The questions to answer in prose

Three sentences each. These are the exercise; the code is how you get to them.

1. The mean MUAC moves when you declare the sentinel. By how much, in which direction, and why is the wrong figure harder to catch than an obviously broken one?

2. Two communes recorded oedema as Y/N rather than true/false. If you had cast that column with astype(bool) instead of mapping it, what would every "false" have become, and what would that have done to the SAM count?

3. Your outcome categorical turned some values into missing. Which values, how many rows, and what should happen next — is this a cleaning decision, a question for whoever entered the data, or both?

How to know you are done

Someone else should be able to run your file on a fresh checkout and get the same printed numbers. If your file contains a path that starts with /Users or C:, you are not done — see lesson 2.

What this exercise is not

It is not asking you to decide what to do about the missing values. Dropping, imputing or reporting them separately is an analysis decision that belongs in a cleaning log, and Data Analysis Foundations covers it. Here you are only making sure a code stops pretending to be a measurement.