Objective
Learning objectives
- Explain what turns raw numbers into "data": rows, columns, observations, and variables
- Classify a column as categorical or numerical and explain why that classification determines what's computable
- Explain why more decimal places is not the same as more accuracy or more meaning
- Diagnose a real units/scale data bug that produces a nonsensical result with no error at all
What you're building
A script (data_audit.py) using this data (or a real small CSV you create with at least 5 rows and 4 columns):
sales = [
{"product": "Widget", "category": "Hardware", "price": 12.99, "units_sold": 340},
{"product": "Gadget", "category": "Hardware", "price": 24.50, "units_sold": 210},
{"product": "Support Plan", "category": "Service", "price": 9.99, "units_sold": 890},
{"product": "Widget Pro", "category": "Hardware", "price": 34.99, "units_sold": 95},
{"product": "Consulting Hour", "category": "Service", "price": 150.00, "units_sold": 40},
]
That:
- Prints each column name labeled as
categorical or numerical, with a one-sentence justification for each - Computes the mean and total of every numerical column, and explicitly states in a comment why doing the same for a categorical column wouldn't make sense
- Contains a comment reproducing this lesson's mixed-units bug on a small dataset of your own invention (not temperatures), showing the wrong average and the corrected one
A dataset has a column called zip_code, holding values like 90210, 10001, 60601. A student wants to compute statistics.mean() on this column to find the "average zip code." What's the accurate assessment?
This is exactly this lesson's insight callout, applied to a genuinely common real mistake. zip_code is stored using digits, and Python's mean() would happily compute a number from it with no error at all — but that number would correspond to no real location and answer no real question. The test for categorical vs. numerical was never "is it written with digits" — it's "does arithmetic on it mean something real," and averaging a location code doesn't.