Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Data Science & Statistics with Python — Alpha School

Lesson 19: Reproducible Workflows and Sharing Your Analysis

A result that only exists on one person's laptop, in a spreadsheet nobody else can follow, is not a result — it is a claim. Reproducible workflows turn a claim into something others can check, reuse and build on. The idea is simple: every step from raw data to final figure should be written down as code, in order, so that running the code again produces the same answer. If a step was done by hand, in a spreadsheet, with no record, it cannot be checked and it cannot be repeated.

The basic structure is a small project folder. The raw data sits in one folder and is never edited. A script — or a notebook with its cells run in order — loads the raw data, cleans it, analyses it, and makes the figures. The final report sits beside it, with the numbers in the text matching the numbers the script produces. When the data is updated, you rerun the script; when someone questions a number, you point to the line that produced it. That is the whole system, and it scales from a school project to a research lab.

Notebooks, Scripts and Versions

Jupyter notebooks are popular for this work because they mix code, output and explanation in one document — you can see the figure right under the code that made it. But notebooks have a trap: cells can be run out of order, so the notebook on screen may not match the order the code actually ran in. The habit that prevents this is to restart and run all cells from the top before sharing, every time. Scripts — plain Python files — avoid the trap entirely, at the cost of keeping the explanation separate.

Version control is the other half of the system. A tool such as Git records every change to your files, so you can see what changed, when, and why, and return to an earlier version if something breaks. Even without Git, the habit matters: keep dated copies of important files, never overwrite the only copy, and write a short note with each version saying what changed. The goal is the same in both cases — no step should be lost, and no result should be unrepeatable.

Sharing So Others Can Check

Sharing means more than sending the final report. Share the data if you can — or say why you cannot — and share the code, with a short readme explaining how to run it. Credit your sources: the dataset, the libraries, and anyone whose work you built on. And choose a licence for your own work, so others know what they may do with it. A shared analysis that can be rerun is a contribution; a PDF alone is a poster.

Sharing Code That Others Can Run

Code that only runs on your computer is only half shared. The most common reason someone else's analysis fails to run is a missing dependency — a library version that differs, a file path that points to a folder on your machine, or a dataset that was never included. The fixes are simple and worth adopting early: list the libraries and versions your project needs, use relative file paths that work from the project folder, and include the data or a link to it. A short readme that says "install these, run this script" turns a pile of files into a project someone else can actually use.

There is a second, subtler barrier: code that is hard to follow. Short, clear variable names, a comment explaining why a step exists rather than what it does, and small functions that do one thing each will make your code readable to a stranger — and to yourself in six months. Readability is not a luxury; it is what makes your work checkable, and checkable work is trustworthy work. The time spent making code clear is repaid the first time someone else finds a mistake in it.

Key Terms

Reproducible workflow
A project where every step from raw data to result is written as code, in order, and can be rerun.
Jupyter notebook
A document mixing code, output and explanation, with cells that can be run in order.
Script
A plain file of code, run from top to bottom.
Version control
Recording every change to files, so earlier versions can be recovered — Git is the common tool.
Readme
A short file explaining what a project contains and how to run it.
Licence
Terms stating what others may do with your work or data.

Discussion Questions

  1. A notebook's cells were run out of order. Why might the results on screen be wrong, even though every cell ran without an error?
  2. Why is 'the spreadsheet on my laptop' not a reproducible workflow?
  3. If you cannot share the raw data, what should you still share — and what should you say?

Practice Questions

  1. What is a reproducible workflow?
  2. Why must the raw data never be edited?
  3. What is the trap with Jupyter notebooks, and how do you avoid it?
  4. What does version control give you?
  5. What should you share alongside a final report?
Show answers
  1. A project where every step from raw data to final result is written as code, in order, so running it again produces the same answer.
  2. So a mistake can always be undone, the original can be checked, and the cleaning can be rerun exactly.
  3. Cells can be run out of order, so the notebook on screen may not match the order the code actually ran in. Avoid it by restarting and running all cells from the top before sharing.
  4. A record of every change — what changed, when, and why — and the ability to return to an earlier version if something breaks.
  5. The data if you can (or why you cannot), the code, and a short readme explaining how to run it — plus credit for your sources.
Keep reading to complete this lesson