ME204 2026 Icon

πŸ–₯️ Week 02, Day 02 - Lecture

Code Makeovers with pandas

Author

Dr Jon Cardoso-Silva

Last updated

21 July 2026

πŸ₯… Learning Objectives

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, and pd.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

Ask your class teacher during the afternoon session.

➑️ Go to Lab Instructions

✍️ Midterm

Due tonight at 8 pm.

➑️ Midterm brief