Objective. Students will structure a multi-step cleaning workflow as a modular Python script with functions, a transformation log, and Git version control so that a peer can reproduce the cleaned output from raw data with a single command.
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
A cleaned dataset is only trustworthy if someone else — or your future self — can recreate it exactly from the raw data. When cleaning lives inside a single, linear notebook cell-by-cell, it is nearly impossible to audit, test, or hand off. A reproducible cleaning pipeline packages every transformation into named functions, records what happened in a log file, and tracks every change through version control. Employers, auditors, and teammates can then run one command and verify the result. This practice is foundational to professional data work and is tested across CompTIA Data+, the IBM Data Science Professional Certificate, and real-world hiring expectations.
Refactoring a notebook into a Python script means replacing ad-hoc cells with named functions, each responsible for one logical step. A clean minimum structure looks like this:
A `main()` function calls these in order. Anyone reading the script sees the full pipeline in five lines. Each function should carry a docstring describing its inputs, outputs, and any assumptions — for example, which column names it expects. Clear function signatures and docstrings are not optional polish; they are the contract between your code and your collaborators.
Python's built-in `logging` module lets you write timestamped records to a file without any third-party library. Configure it once near the top of your script:
```python
import logging
logging.basicConfig(
filename='pipeline.log',
level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s'
)
```
Then, inside each function, log what happened and how many rows were affected:
```python
logging.info(f'{dupes} duplicate rows removed')
logging.info(f'{reformatted} dates reformatted to ISO 8601')
```
The resulting log file is an audit trail — a permanent, human-readable record showing exactly what the pipeline did and when. If a downstream report looks wrong, the log is the first place you check. Logging counts and shapes (not cell-by-cell print statements) is a professional standard because it works the same way whether the script runs on your laptop or on a remote server.
Git tracks every change to your code as a commit, a snapshot with a message explaining what changed and why. For a cleaning pipeline, a disciplined commit history might look like:
1. `init: add raw dataset and script scaffold`
2. `feat: implement load_raw with path validation`
3. `feat: implement clean_strings — strip whitespace, normalize case`
4. `feat: implement impute_missing — median fill for numeric cols`
5. `feat: implement export_clean and add logging config`
6. `docs: add README with run instructions`
Each commit message starts with a short verb phrase. Vague messages like `fixed stuff` are useless six months later. The commit history becomes documentation of your reasoning.
GitHub hosts a remote copy of the repository. Pushing to GitHub lets a partner clone your repo, run the pipeline, and check that their output matches yours — which is the definition of reproducibility.
A README file (plain text or Markdown) lives in the repository root and answers three questions for any new reader:
1. What does this pipeline do? — one or two sentences.
2. What do you need to run it? — Python version, any libraries (`pandas`, etc.), and how to install them (e.g., `pip install -r requirements.txt`).
3. How do you run it? — the exact single command, such as `python clean_pipeline.py --input data/raw.csv --output data/clean.csv`.
A README that passes those three tests means a peer can reproduce your work with no verbal explanation from you.
To confirm two output files are identical, compare their SHA-256 hashes. A hash function converts any file into a fixed-length string; if even one byte differs, the hash changes completely. On the command line: `sha256sum output/clean.csv`. If your partner's hash matches yours, the reproduction is confirmed. This check removes subjectivity — you are not eyeballing rows, you are comparing a mathematical fingerprint.
Reproducible pipelines handle raw data that may contain personally identifiable information (PII). Never commit raw data files to a public GitHub repository. Add data files to `.gitignore` before your first commit, and store sensitive files on approved internal drives or private repositories only. Your organization's data governance policy — and federal and state privacy rules — apply regardless of how the data flows through your pipeline. Always confirm with your instructor or employer what may and may not be pushed to a cloud host.
A reproducible cleaning pipeline combines three independent skills — modular code, audit logging, and version control — into one professional workflow. Each skill reinforces the others: functions make individual steps easy to log; logs make commits meaningful; commits make the README accurate. When your partner clones your repository and the hashes match, you have demonstrated that your data preparation is trustworthy, auditable, and shareable — the standard every data analytics employer expects.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.