When students complete a dissertation using Python, the main focus is usually on getting the analysis and results correct. I have experienced this myself while working with Python for data analysis, machine learning and research.
But there is another issue that is easy to overlook: will the same code work on another computer? A Python script may run perfectly on your laptop but fail when your supervisor or another researcher tries to execute it. This is where reproducible Python analysis becomes important.
The short answer
Make your analysis reproducible by recording your Python and package versions (a pinned requirements.txt), working in a virtual environment, setting random seeds, using relative file paths and including clear run instructions in your appendix.
What does reproducibility mean in Python?
Reproducibility means that another person should be able to understand your analytical process and, where possible, run the same code and obtain comparable results.
When I started working with Python, libraries such as Pandas made data analysis relatively straightforward. However, as projects became more advanced and involved machine learning and statistical analysis, I realised that the code itself was only one part of the project. The Python environment also matters.
Why “it worked on my laptop” is not enough
Imagine that your dissertation uses Pandas, NumPy, Scikit-learn, Statsmodels and Matplotlib. Your code works correctly today, but several months later a library has been updated. A supervisor running your code may then receive an error even though your original analysis worked.
I have found that this becomes particularly important when working with machine-learning workflows, where different package versions can affect how code, models or functions behave.
| Common cause | What goes wrong | Simple fix |
|---|---|---|
| Unpinned package versions | Functions are renamed or defaults change | Pin versions in requirements.txt |
| Absolute file paths | C:/Users/me/Desktop/data.csv does not exist elsewhere | Use paths relative to the project folder |
| Random processes without a seed | Train/test splits and models change on every run | Set a random seed |
| Hidden notebook state | Cells run out of order work only on your machine | Restart and run all before submitting |
| Manual data edits | Changes made in Excel are not recorded | Do all cleaning in code |
What should students document?
A simple solution is to create a requirements.txt file containing the packages required by your project. For example:
pandas numpy scikit-learn statsmodels matplotlib seaborn
You can make this even more useful by recording the package versions you actually used:
pip freeze > requirements.txt # requirements.txt then contains exact versions, for example: # pandas==2.2.2 # statsmodels==0.14.2
The version numbers shown are examples. Use the ones produced by pip freeze on your own computer.
Use a virtual environment
Using a virtual environment is another good practice. It keeps the dependencies for one research project separate from other Python projects on your computer.
# Create and activate an environment (Windows) python -m venv .venv .venv\Scripts\activate # macOS / Linux python3 -m venv .venv source .venv/bin/activate # Install what the project needs pip install -r requirements.txt
If you use Anaconda, conda env export > environment.yml does the same job. Either way, a marker can rebuild the environment you used instead of guessing.
Set random seeds for consistent results
Machine learning, bootstrapping and train/test splits all involve randomness. Without a fixed seed, accuracy scores and confidence intervals can change slightly every time the code runs, which is confusing when the numbers in your dissertation do not match the rerun.
import numpy as np
from sklearn.model_selection import train_test_split
SEED = 42
np.random.seed(SEED)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=SEED)Organise your project folder
A clear folder structure makes it obvious where everything belongs and lets your code use relative paths:
dissertation-analysis/ ├── data/ │ ├── raw/ # original data, never edited │ └── processed/ # cleaned data created by code ├── scripts/ │ ├── 01_cleaning.py │ ├── 02_analysis.py │ └── 03_figures.py ├── outputs/ # tables and figures ├── requirements.txt └── README.md # how to run everything
Numbering scripts in the order they should run removes guesswork for anyone checking your work.
What should go in a dissertation appendix?
Based on my experience, students should think beyond simply attaching a .py file. A useful appendix can include:
- Python version
- Required libraries and versions
- requirements.txt
- Source code
- Data-processing steps
- Instructions for running the code
- Relevant model or analysis settings
This makes it easier for someone else to understand how your results were produced.
A sample README for your appendix
# Dissertation analysis: Study habits and exam performance Python 3.11. Packages listed in requirements.txt. 1. Create environment: python -m venv .venv 2. Install: pip install -r requirements.txt 3. Place survey_raw.csv in data/raw/ 4. Run scripts in order: python scripts/01_cleaning.py python scripts/02_analysis.py python scripts/03_figures.py 5. Tables and figures are saved to outputs/ Random seed: 42. Data are not shared publicly for ethical reasons; a synthetic sample is provided in data/sample.csv.
If your data are confidential, explain this and, where your ethics approval allows, provide a small anonymised or synthetic sample so the code can still be tested.
Final reproducibility check before submission
- Copy the project folder to a new location or another computer.
- Create a fresh virtual environment and install from requirements.txt.
- Run every script (or notebook) from top to bottom.
- Compare the regenerated tables and figures with those in your dissertation.
- Fix any differences before you submit.
Tip: Jupyter users should use Restart Kernel and Run All as the final test. Many notebook errors only appear when cells run in order.
Version control with Git
Version control records every change to your code, so you can see what changed, when and why, and go back to an earlier version if something breaks. Even a simple Git repository with clear commit messages, such as “add outlier rule for income”, creates a useful history for your supervisor. Platforms like GitHub or GitLab also let you share a private repository with your marker instead of emailing zip files.
git init git add scripts/ requirements.txt README.md git commit -m "Initial analysis pipeline"
Reproducibility levels: from basic to advanced
| Level | What you do | Good enough for |
|---|---|---|
| Basic | Share commented code and a list of packages | Short assignments |
| Standard | Pinned requirements.txt, virtual environment, README, seeds | Most dissertations |
| Strong | Git history, automated tests or checks, synthetic sample data | Theses, publications |
| Advanced | Containers such as Docker that capture the whole system | Research software and long-term archives |
Most students only need the standard level. Aim for that first, then add more only if your project or department requires it.
Common reproducibility mistakes
- Saving cleaned data only as a manually edited Excel file.
- Keeping unused experimental code that confuses the reader.
- Including the entire base environment in requirements.txt instead of only project packages.
- Hard-coding results into the text instead of producing them from code.
Reproducibility and academic integrity
Reproducible code also protects you. If a marker questions a result, you can show exactly how it was produced. Transparent, rerunnable analysis demonstrates that your findings come from your data and methods rather than manual adjustments, which supports the integrity of your dissertation. Many universities and journals now encourage or require code and data availability statements, so building these habits during your degree prepares you for research and professional work.
Notebooks vs. scripts for reproducibility
Jupyter notebooks are convenient for exploration and explanation, but they can hide problems when cells are run out of order or edited after running. Scripts run top to bottom every time, which makes them more predictable. A practical compromise is to explore in notebooks and move the final, cleaned workflow into numbered scripts, or to always restart and run all cells before saving the final notebook.
Checklist: is my Python analysis reproducible?
- A fresh environment can be built from requirements.txt or environment.yml.
- All file paths are relative to the project folder.
- Random seeds are set wherever randomness is involved.
- Raw data are never edited by hand; all cleaning happens in code.
- A README explains the order in which to run scripts.
- Rerunning the code reproduces the tables and figures in the dissertation.
If you can tick every item, your supervisor or examiner should be able to rerun your work with very little effort.
How Analytivio can help make your analysis reproducible
Analytivio is a data analytics consultancy supporting students, researchers and businesses with analysis they can trust and explain. For reproducible Python analysis, we can help you:
- Review your scripts and fix code that only runs on one machine.
- Set up requirements files, environments and a clear folder structure.
- Write a README and appendix instructions your marker can follow.
- Rerun the full analysis to confirm your reported results match.
We explain every step in plain language, so you understand your results and can defend them to a supervisor, examiner or client. Message us on WhatsApp for a free consultation, or explore our data cleaning and processing services.
How reproducibility affects your marks
Many marking schemes for quantitative dissertations reward transparency, clear methodology and accurate reporting. Reproducible code supports all three. When a marker can see exactly how data were cleaned and analysed, they are more confident in your results and less likely to question unexplained numbers. Even when code is not formally assessed, a tidy, rerunnable project reflects careful research practice. It also protects you during a viva or a query from your supervisor, because you can regenerate any table or figure quickly instead of trying to remember what you did months earlier.
Sharing code with your supervisor
Send your supervisor the whole project folder or a private repository link, not individual files. Include the README at the top level so they know where to start, and mention any files you could not share, such as confidential raw data.
Frequently asked questions
What is reproducible analysis in Python?
It means someone else can understand your process and rerun your code to get comparable results, using the same data, package versions and settings.
Do I need to include requirements.txt in my dissertation?
It is strongly recommended when you use Python. It tells your marker exactly which packages and versions your analysis depends on.
Should I use pip freeze or write requirements by hand?
pip freeze records the exact versions installed in your environment. Run it inside a project-specific virtual environment so the list only contains what the project needs.
Why do my results change each time I run my model?
Usually because a random process, such as a train/test split, has no fixed seed. Set a random_state or seed to make results repeatable.
Can I share my code if my data are confidential?
Yes. Share the code and environment details, explain why the data are restricted and, if allowed, provide a synthetic or anonymised sample.
Is Docker necessary for a dissertation?
Usually not. A pinned requirements file, a virtual environment and clear instructions are enough for most dissertations. Docker is useful for complex research software.
Want your Python analysis checked before submission?
We can rerun your code in a clean environment, fix anything that breaks and prepare appendix documentation your supervisor can follow.
Keep reading
This article is general guidance. Library features change between versions, so always check the official documentation for the version you use.



One response
[…] PythonReproducible Python Analysis for Your Dissertation AppendixPythonBeyond Pandas: When to Use Statsmodels or PingouinOur serviceResearch & Academic Data Help […]