Lesson 6.8: Review & Rehearse – Data Debugging and Practice

Today’s Goals

  • Review Unit 6 concepts (datasets, cleaning, filtering, sorting, nested data)
  • Practice debugging real dataset code
  • Prepare for the Unit 6 Exam

Warm-Up Question

  • Which Unit 6 skill do you feel most confident about? Which needs more practice?

Review Topics

  • Lists & dictionaries for datasets
  • Cleaning data (dropna, drop_duplicates, astype)
  • Filtering and sorting with pandas
  • Aggregations: mean, median, std
  • Nested data structures
  • Debugging errors (IndexError, ValueError, FileNotFoundError)

Buggy Code Example

import pandas as pd

data = {
    'name': ['Alice', 'Bob', 'Charlie'],
    'score': [90, 'eighty', 85]
}

df = pd.DataFrame(data)
print(df['score'].mean())   # ❌ Error here

Fixing the Bug

df['score'] = pd.to_numeric(df['score'], errors='coerce')
print(df['score'].mean())

Class Activity

  • Work in pairs on buggy dataset scripts
  • Fix as many as you can in 25 minutes
  • Record what the bug was and how you fixed it

Student Challenge

  • Complete a mini-project using your chosen dataset:
    • Clean the dataset
    • Perform filtering, sorting, aggregation
    • Create at least one visualization

Wrap-Up

  • Debugging practice makes you faster at problem solving
  • Next time: Unit 6 Exam