This folder contains two Jupyter notebooks designed to help students learn by debugging intentional errors commonly encountered in data science and machine learning workflows.
By completing these notebooks, students will:
- Understand how Jupyter kernel state and cell execution order work
- Debug common file path and module import errors
- Handle data type mismatches and missing values
- Recognize and fix shape incompatibilities in NumPy and scikit-learn
- Prevent variable overwriting and namespace issues
- Learn when kernel restart is necessary
- Practice systematic debugging strategies
jupyter-error-lab/
│
├── 01_notebook_errors.ipynb # Jupyter & environment fundamentals
├── 02_data_and_ml_errors.ipynb # Data science & ML pipeline errors
│
├── data/
│ ├── sample_data.csv # Lowercase filename
│ ├── Sample_Data.csv # Uppercase (for case-sensitivity demo)
│ └── wrong_format.txt # Non-CSV file for format error demo
│
├── fake_modules/
│ └── pandas.py # Fake module for shadowing demonstration
│
└── README.md # This file
-
Setup: Share this repository with students via Git clone, download, or LMS upload.
-
Instruct students to:
- Open
01_notebook_errors.ipynbfirst - Run cells top to bottom one at a time
- Observe each error carefully
- Read the explanation in markdown cells
- Apply the suggested fix
- Open
-
Classroom Flow:
- Self-paced: Students work individually, asking for help when stuck
- Guided walkthrough: Project notebook and discuss each error as a class
- Pair programming: Students debug together in pairs
-
Assessment Options:
- Ask students to fix all errors and submit corrected notebooks
- Quiz on error types and their fixes
- Have students write their own error examples
IMPORTANT INSTRUCTIONS
- DO NOT skip cells or run out of order
- DO NOT fix all errors immediately—learn from each one first
- DO restart kernel (Kernel → Restart) when instructed
- DO read error messages carefully before looking at explanations
BEFORE YOU START:
- Each notebook includes "Concept" sections explaining theoretical background
- Read the "Key Concepts You'll Learn" section at the top of each notebook
- Pay attention to conceptual explanations—they help you understand WHY errors occur
- Understanding theory helps you debug faster in real projects!
Workflow:
- Open
01_notebook_errors.ipynb - Read the "Key Concepts You'll Learn" section at the top
- Run first code cell
- When you see an error:
- Read the error message carefully
- Check the "Concept" explanation above the error (if present)
- Try to understand what went wrong
- Read the markdown explanation below
- Apply the fix (uncomment correct version or edit cell)
- Repeat for each error scenario
- Move to
02_data_and_ml_errors.ipynbwhen done
Install required packages:
pip install jupyter numpy pandas matplotlib scikit-learn tqdm- Python 3.10.11 (recommended and tested)
- Notebooks: Two error-filled notebooks with embedded conceptual explanations
- Data files: Sample CSV and text files for demonstrations
- Supporting files: Fake modules for import shadowing examples
- IndentationError / SyntaxError (with indentation concept explanation)
- Cell Not Executed → NameError
- Kernel Restart Clearing Variables (with kernel concept explanation)
- Import Works Once, Fails Later (with import caching explanation)
- Relative Path Changes After os.chdir (with path concepts)
- Multiple Notebooks Same Kernel Confusion
- FileNotFoundError - Wrong Relative Path
- Case-Sensitive Filename Issue
- File Exists Locally But Not in Notebook Directory
- Reading Wrong File Format
- ModuleNotFoundError
- Shadowed Module Name
- Restart Required After Install
- No Output Displayed - Missing Print
- Output Truncation for Large DataFrame
- Plot Not Displaying
- Variable Overwriting
- Function Defined But Not Called
- Shape Mismatch in NumPy/Sklearn (with array shape concepts)
- Pandas KeyError - Missing Column (with DataFrame column concepts)
- IndexError (Out-of-Bounds Access)
- NaNs Causing Model Failure (with missing value concepts)
- Wrong Data Types in DataFrame (with dtype concepts)
- Silent Dtype Upcasting (with type coercion explanation)
- Train-Test Column Mismatch
- Train-Test Leakage (comprehensive data leakage explanation)
- Randomness / Non-Reproducibility (with random seed concepts)
- Long-Running Cell With No Feedback
- Accidental File Overwrite on Disk
- PermissionError
- Infinite Loop
- Memory Error Scenario
- Kernel Freeze Explanation and Prevention
Some errors require kernel restart to demonstrate properly. When instructed:
- Click Kernel → Restart in menu
- Re-run only the cells specified in instructions
- Observe the error or behavior change
- No external downloads: All data is included
- No actual crashes: Dangerous operations are commented out with explanations
- Isolated errors: Each error is self-contained
- Take your time—don't rush through errors
- Type fixes yourself rather than just uncommenting
- Experiment: try variations to deepen understanding
- Keep a "debugging cheatsheet" of common fixes
- Encourage students to explain errors to each other
- Use these as starting point for creating your own error examples
- Consider recording screencasts of debugging process
- Adapt difficulty by adding/removing explanations
Happy Debugging!
Remember: Every error is a learning opportunity. The best developers aren't those who never make mistakes—they're the ones who know how to fix them efficiently.