Episode 8: The Data Room
Programming with Python · Tutorial 08
The investor wasn’t impressed by a slide. She was impressed by data. So she slides a USB stick across the table: every order, two full weeks. “Impress me.” That stick is now a real file, orders_messy.csv. Tobi exported it from the ordering system and nobody has looked at it since. It has too many rows to eyeball and too many for a hand-written loop, so this week you use the tool built for exactly this: pandas. You’ll load the file into one DataFrame, filter it with boolean masks, add a derived column on a safe copy, and answer per-zone questions with groupby. Tobi, meanwhile, has discovered AI. Your real job is to supervise it and catch the confident nonsense.
Run the lab on your laptop
From this episode the lab is a Python script that runs on your own machine, in the python-labs folder you created in Session VII. Missed that session? The Tutorial 07 page says how to catch up.
Download both files and move them into your
python-labsfolder:In Zed, open the
python-labsfolder, then the terminal (Ctrl+`).Run
uv run python lab_08_dataroom.py.
Use a GitHub codespace: a Linux computer that runs in a browser tab.
Sign in at github.com/codespaces and start the Blank template. If you set one up in Session VII, open it again and go to step 3.
In its terminal, follow the uv guide (the macOS or Linux lines) down to
uv add pandas matplotlib.Go into the folder with
cd python-labsand download both files:curl -O https://python.tobiasvlcek.com/labs/lab_08_dataroom.py curl -O https://python.tobiasvlcek.com/labs/orders_messy.csvRun
uv run python lab_08_dataroom.py.
A codespace has no Zed, so keep the chatbot open in a second tab for AI help.
The first run prints three tables and then stops with AssertionError: Task 1: not attempted yet. That is the lab working: the script checks every task and stops at the first one whose answer is missing or has the wrong form. Solve it, save, and run again.
If the run ends in ModuleNotFoundError: No module named 'pandas' instead, the terminal is not inside python-labs, or the packages are missing. In that folder, run uv add pandas matplotlib once.
Each task gives you a symptom (“Hafen is missing orders”), and you find the cause. The checks only test the form of your answers, so a wrong number can pass all of them. And one problem in the export is not mentioned anywhere: no task names it and no check catches it.
When every check passes, the script prints a block that starts with SHOW THIS IN CLASS. Show it to your lecturer, who compares your numbers with the right ones. That is feedback, not a condition for leaving: if a number differs, you hear which one, and whether you fix it is up to you. Not finished when the session ends? Finish at home. You do not need to show the block later.