π₯οΈ Week 02, Day 02 - Lecture
Code Makeovers with pandas
By the end of the lecture, you should be able to: i) Check midterm submission hygiene before 8 pm (API key, notebook hygiene, and what still counts as Good-Very Good with loops), ii) Replace duplicated city or year blocks with one loop over dictionaries, iii) Use optional pandas tools when useful: .assign(), pd.to_datetime, .dt, Boolean filtering, and pd.concat, iv) Walk a pipeline that builds a list of dictionaries into equivalent pandas steps and check each step with .shape and .head(), v) Write a short refactoring note that states what changed and how you checked it.
β° Tuesday, 21 July 2026 | 10:00am - 1:00pm π CBG.2.01 (see LSEβs πΊοΈ campus map)
In preparation for your midterm, which is due at 8 pm tonight, I will show a few pandas tools you can use to make your code more efficient and readable.
π£οΈ Lecture Overview
- Before you submit tonight: Things to check before you hand in
- Code Makeover A: more on the JSON to CSV transformation patterns we did yesterday
- A few new pandas tricks:
.assign(),pd.to_datetime,.dt, Boolean filtering, andpd.concat(optional for tonight) - Code Makeover B: a walk through code using
pandas - What are you stuck on?
π¬ Lecture Slides
Use keyboard arrows to navigate. Select the slides below or view fullscreen.
After the Lecture
This afternoon is Super Tech Support. Your class teacher will help with general queries so you can make progress on the midterm before the 8 pm deadline. There is no new exercise.
Super Tech Support