Take a survey from its regional databases to published tables, then find what is wrong in it.
You work in marimo notebooks with pandas, polars and DuckDB on a survey of fishing households kept the way survey data often is: one database per region. You read every region in one query, match the keys between tables, write edit rules as data, recode and tabulate, estimate under the survey design with svy, and publish to Excel from a script you can run again. Then you find anomalies two ways: with rules and statistics, and with machine learning in scikit-learn and PyOD. An optional stretch closes the course with a showcase of what AI agents, hosted or on your own machine, can do for this pipeline, and how to keep your data safe when you use them.
The course follows Arrays & DataFrames: you need what it covers (pandas and polars, reading files with the right types, groupby, joins, survey weights). Python for Data Management is recommended, since modules 2 and 4 build on its database work and pipelines. If you come from R, primer P1 sets each verb you know beside its Python; if survey sampling is new to you, primer P2 explains it on one page.
The data is the Survey of Fishing Households 2025, a survey invented for this course: its tables, variable names, sampling design, households, fishing units, catch, weights and interviewers are made up for teaching. Its places are real: the region, province and city or municipality codes and names are the PSGC’s, 3rd quarter 2026.
The modules
Section titled “The modules”Each module is one topic, taught in sections; a training groups them into its own days or sessions.
- Module 1, Start here
- Module 2, Get the tables: from regional databases to one flat table
- Module 3, Match the keys
- Module 4, Edit rules and duplicates
- Debugging drill D1, Debugging drill: a flat table that lies
- Stretch exercises S1, Stretch: processing
- Module 5, Recode and tabulate
- Module 6, Estimate under the survey design
- Module 7, Publish the tables
- Stretch exercises S2, Stretch: tabulation
- Module 8, Anomalies by rule and by statistics
- Module 9, Anomalies with machine learning
- Debugging drill D2, Debugging drill: a detector that flags the wrong rows
- Stretch exercises S3, Stretch: detection
- Stretch exercises S4, Stretch: agents for your pipeline, a showcase
- Capstone
For any time
- Primer P1, Primer: from R to Python
- Primer P2, Primer: survey sampling in one page
- Glossary
When you are stuck
Section titled “When you are stuck”Every exercise has a check that names the input that went wrong, and a note of common causes. If you are still stuck after ten minutes, or your check is green and you want to compare, the companion has the solution to each exercise and why it works.