Reproducible Analysis Projects
Structuring folders, environments, parameters and documentation so an analysis can be rerun by someone else months later.
Intermediate · about 3 hours · difficulty 2/5
Learn first: Git and GitHub for Analysts
An analysis is reproducible when a colleague can take your folder, run it, and get the same numbers. That matters for audits, recurring reports and your own sanity.
A simple project layout
project/
README.md # question, data sources, how to run
data/raw/ # never edited by hand (ignored by Git)
data/processed/ # generated by code
queries/ # SQL
notebooks/ # exploration, numbered 01_, 02_
src/ # reusable Python functions
reports/ # final outputs
requirements.txt # or environment.yml
Environments
Pin library versions with requirements.txt (pip and venv) or environment.yml (conda), or use uv or Poetry. A notebook that worked with pandas 1.x may break on 2.x.
Rules that make reruns work
- Raw data is read only; every change happens in code.
- No hard-coded absolute paths; use paths relative to the project root.
- Parameters (dates, thresholds) live in one config cell or file.
- Notebooks should run top to bottom after "Restart and Run All".
- Record the data extract date and query used.
Secrets and connections
Store credentials in environment variables or a .env file excluded from Git, never in notebooks.
Pitfall: a final number that only exists because cells were run out of order. You are ready to move on when someone else can clone your repo, install the environment and reproduce your headline figure without asking you anything.
Key concepts
- Project folder conventions
- Raw vs processed data
- Virtual environments and pinned versions
- Relative paths and config
- Restart and Run All discipline
- Secrets in environment variables
- Cookiecutter project templates
Mini project
Restructure an old analysis into the standard layout, add a requirements file and README run instructions, then ask a friend to reproduce your main chart from a fresh clone.
Check yourself
Name three things that commonly stop a notebook from producing the same result on another machine.
Free resources
- Python venv documentation (Python)
- Cookiecutter Data Science (DrivenData)