Week 02: Exercises & Checklist
Graded exercises
Easy: Run
notebooks/01-pandas-cleaning.ipynbto completion. It prints, at the end, the cleaned row count and the number of duplicate rows removed. Record both numbers in the Week 2 tracker sheet.Standard: Profile the raw dataset and document five planted issues: (1) duplicate rows, (2)
NaNweights, (3)NaNlane distances, and two more you find yourself (look atdelay_hoursfor impossible values,weight_kgfor non-positive values, orstatusfor rows whoseactual_arrivalcontradicts the label). For each, write the finding, the evidence (a count or a sample row), and the fix in your profile report.Stretch: In
notebooks/02-sql-with-duckdb.ipynb, rewrite the "on-time rate by carrier/lane/month" query using a window function (e.g.AVG(...) OVER (PARTITION BY carrier_id, lane_id, month ORDER BY month)) instead of a plainGROUP BY, and add a cell asserting the two approaches agree within floating-point tolerance.Portfolio: Advance the ZoroLogistics data generator + silver dataset milestone (see
curriculum/projects/README.md): turn the cleaning workflow into a runnable scriptdata/make_silver.pythat regenerates (or loads) the raw data, cleans it, runs the validation suite, and writesdata/silver/. One command, one reproducible silver table.
Hints
- Easy: The final cell prints two numbers:
CHECKS_PASSEDandSILVER_ROW_COUNT. Record both; ifCHECKS_PASSEDis not 12, scroll up to the firstFAILline and fix that decision before re-running. - Standard: For the two unplanted issues, profile
delay_hours(look at itsdescribe()tail for extreme values) and check the relationship betweenplanned_arrivalandplanned_departure, a row where arrival precedes departure is a structural defect. - Stretch: A window function keeps every row, so wrap the per-carrier monthly rate in a CTE and add
AVG(...) OVER (PARTITION BY carrier_id); then assert the two approaches agree withnp.allclose. - Portfolio: Structure
make_silver.pyas three functions,load_or_generate(),clean(df),validate(df) -> bool, so the script reads as the sameraw → clean → validate → saveflow the notebook does, but in one command.
Checklist (mirrors manifest.json + Excel tracker)
- [ ] Mon: Study data quality concepts; run the pandas refresher exercises.
- [ ] Tue: Run the pandas cleaning notebook; find and document 5 data issues in the generator output.
- [ ] Wed: Write SQL queries in DuckDB: on-time rate by carrier/lane/month, windows, top-lane analysis.
- [ ] Thu: Add a data validation suite (pandera) with at least 10 checks.
- [ ] Fri: Use case: deliver the cleaned silver dataset + profile report; document every cleaning decision.
- [ ] Sat: Take the Week 2 quiz (quiz.md), pass with 8/10; record the score in Notes.
- [ ] Milestone: Update the Excel tracker; commit the silver pipeline script.