How to turn a messy file into a table you can trust: column types, labels, numbers and dates stored as text, duplicates, missing values, outliers, joins, and SQL with DuckDB. The running example is a decision that reverses once the data is cleaned.
Slides¶
Present full screen Download the PDF
Click or tap the slide to move forward, its left edge to go back; the arrow keys work too.
Reading¶
Data Wrangling: Clean Data Before You Decide walks through every cleaning step on Qahwa House’s purchases file, with code you can run, and shows how the cleaned data reverses the choice of milk supplier.
Lab 2: Clean and join a messy dataset¶
Qahwa House buys milk from two suppliers and wants to keep one. The purchases file was typed by hand at four branches: names spelled several ways, prices stored as text, three date formats, duplicates, gaps and typos. You clean it, join it with the product table, summarise it in pandas and in SQL, and recommend a supplier.
Open the lab, then use its Open in Colab button.
Data: qahwa
_purchases _messy .csv (644 deliveries) and qahwa_products.csv (4 products). The notebook downloads both by itself. Submit before the next lab session. The solutions are for checking your work afterwards.
Next week¶
Describing data: summary measures, histograms, box plots and time-series plots.