Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2. Data Wrangling

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.

Next week

Describing data: summary measures, histograms, box plots and time-series plots.

→ Week 3: Describing Data