DataScrub
A Python package for cleaning pandas DataFrames. It drops into a scikit-learn pipeline and can work through files too big to fit in memory.
What it is
I wrote DataScrub in June 2023 because I kept writing the same cleaning code for every pandas project. It’s a personal open-source package, published to PyPI through a GitHub Actions workflow.
In March 2026 I rewrote it as version 2. Everything goes through one DataClean class and a single prep() call. It can fill missing values (including with KNN imputation), clip outliers by IQR or z-score, drop duplicates, clean up text, parse dates and pull features out of them, scale columns, and encode categories as one-hot, label or target encodings. A summary() method reports how sparse each column is, how much memory it uses, and its variance and skew.
The hard parts
I wanted it to fit into a scikit-learn Pipeline next to a model, so DataClean is a proper transformer, built on BaseEstimator and TransformerMixin.
Version 2 also handles files bigger than memory. It reads a CSV in chunks, cleans each chunk and writes it straight to disk, and it switches to this mode on its own for files over 100 MB. An optional PyArrow backend and a downcast() step that shrinks numeric columns where it’s safe keep memory down further. Through all of it, I tried to keep the API small enough for a quick script.
What I had to work with
Working in chunks has a cost. Each chunk is cleaned on its own, so anything that depends on statistics (median imputation, scaling, outlier bounds, encodings) is calculated per chunk rather than over the whole file.
How it turned out
It’s on PyPI at version 2.0.1, its eleventh release, with 17 tests covering the main cleaning paths.