Skip to main content

Universal Data Cleaner

CI Docs PyPI Python 3.10+ License: MIT Managed with uv

A small, production-oriented tabular cleaning transformer for pandas + scikit-learn.

It is designed for the part of an ML pipeline that is easy to get wrong: cleaning training data and inference data with exactly the same learned rules.

Documentation

Full documentation →

The docs site is the central reference. This README is the short entry point.

Guide What it covers
Quickstart Install, first cleaner, scikit-learn pipeline
Leak-safe workflow The fit/transform contract and common mistakes
Cleaning data Config, roles, imputation, outliers, datetimes
Contracts & drift ColumnSpec, DataContract, drift checks
Statistical drift PSI, Wasserstein distance, missingness and category deltas, batch history
Safe ingestion Contract-driven CSV, Excel, and Parquet reads with ingestion reports
Batch reporting CleanerReport and the data-cleaner audit CLI
Validation, joins & dedup Expectations, cross-column and conditional rules, join diagnostics, dedup
ML split audit Duplicate, group, temporal, and target leakage
Artifacts & reproducibility Decision log, manifests, fingerprints, save/load
Production guide Deployment checklist and failure modes
Performance and large data Benchmarks, memory guidance, chunked workflows
API reference Generated from the package docstrings
Changelog Release notes
Upcoming What ships next and what is out of scope

Install

pip install universal-data-cleaner
uv add universal-data-cleaner

The distribution name is universal-data-cleaner; the import name is data_cleaner.

For Excel input, install the optional extra:

pip install "universal-data-cleaner[excel]"
uv add "universal-data-cleaner[excel]"
from data_cleaner import CleanerConfig, DataCleaner

Quick start

import pandas as pd
from data_cleaner import CleanerConfig, DataCleaner

train = pd.DataFrame(
    {
        "age": [34, 41, None, 29],
        "salary": [70_000, 82_000, 91_000, 55_000],
        "dept": ["IT", "HR", "IT", None],
        "joined": ["2022-01-03", "2021-11-20", "2023-04-01", "bad-date"],
    }
)

config = CleanerConfig(
    datetime_columns=("joined",),
    add_missing_indicators=True,
    drop_constant_columns=True,
)

cleaner = DataCleaner(config).fit(train)
train_clean = cleaner.transform(train)

fit() learns medians, modes, outlier bounds, category values, and datetime rules from train. transform() applies those stored rules without learning from the frame you pass in.

Leak-safe by construction

cleaner = DataCleaner(config).fit(X_train)

X_train_clean = cleaner.transform(X_train)
X_test_clean = cleaner.transform(X_test)  # training rules only

Never fit before splitting, and never create a new cleaner for test or production data. See the leak-safe workflow for the full explanation.

What it handles

  • numeric coercion, median / mean / constant imputation, IQR capping, and exact int64 preservation with explicit precision-loss policies
  • categorical mode / constant imputation and a keep-or-fill unseen policy
  • boolean coercion and imputation
  • datetime parsing plus calendar feature extraction
  • optional missing-value indicators and constant-column dropping
  • safe CSV, Excel, and optional Parquet ingestion with contract-driven coercion, identifier protection, date and boolean guards, and an audit report
  • CleanerReport combining profile, contract drift, validation, ingestion, and cleaner decisions, plus a data-cleaner audit CLI
  • declarative contracts with roles, allowed values, ranges, patterns, and uniqueness
  • automatic train-schema contract inference, transform-time drift reports, and transform_with_report() for concurrency-safe batch reporting
  • chunked transformation with transform_chunks() and run-level report aggregation through combine_drift_reports()
  • expectation checks and validation reports, plus cross-column, conditional, and grouped rules with bounded, privacy-safe failing-row diagnostics
  • statistical drift against a reusable reference profile: PSI, Wasserstein distance, missingness and category deltas, and a JSON Lines batch history
  • join diagnostics, referential integrity, and audited business-key dedup
  • train/test split audits for duplicate, group, temporal, and target leakage
  • joblib save / load with atomic writes, manifests, runtime compatibility checks, and stable data fingerprints
  • scikit-learn Pipeline, clone, and get_feature_names_out compatibility
  • stable output schema and column order; inputs are never mutated and inference rows are never dropped

Large data

transform() keeps one batch in memory. For files that do not fit, stream chunks and aggregate the reports:

from data_cleaner import combine_drift_reports, iter_csv_safe

clean_reports = []
for chunk, _ in iter_csv_safe("events.csv", contract=contract, chunksize=100_000):
    cleaned, drift = cleaner.transform_with_report(chunk)
    clean_reports.append(drift)
    write_batch(cleaned)

report = combine_drift_reports(clean_reports)
report.raise_if_errors()

Parquet input is available with the parquet extra (pyarrow). Measured throughput, memory guidance, and the supported workload are in Performance and large data; the reproducible suite lives in benchmarks/.

Development

git clone https://github.com/devlprkhan/universal-data-cleaner.git
cd universal-data-cleaner
uv sync --dev
uv run pytest -q

Run the full quality gate:

uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest
uv build

Build or preview the docs:

uv sync --group docs
uv run --group docs mkdocs serve
uv run --group docs mkdocs build --strict

The reference notebook is Universal_Data_Cleaner.ipynb. Open it with:

uv run jupyter lab Universal_Data_Cleaner.ipynb

Project layout

src/data_cleaner/                  # typed, pip-installable package
tests/                             # unit and integration tests
docs/                              # MkDocs guides, API page, and assets
mkdocs.yml                         # documentation site configuration
Universal_Data_Cleaner.ipynb       # end-to-end reference workflow
pyproject.toml                     # package metadata and tooling
uv.lock                            # reproducible dependency lock
CHANGELOG.md                       # release notes
CONTRIBUTING.md                    # development workflow
SECURITY.md                        # vulnerability reporting
LICENSE                            # MIT license

The package ships a py.typed marker, so mypy, pyright, and IDE tooling pick up the type annotations automatically. Linting, formatting, type checking, tests, the docs build, and package build run in CI.

Contributing

Contributions are welcome. See CONTRIBUTING.md for the local setup, quality gate, and pull-request expectations.

License

Released under the MIT License.

Metadata

Release files for universal-data-cleaner 2.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for universal-data-cleaner 2.12.0
File Size Uploaded Provenance Actions
universal_data_cleaner-2.12.0.tar.gz 120.1 kB With provenance Details for universal_data_cleaner-2.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for universal-data-cleaner 2.12.0
File Interpreter ABI Platform Actions
universal_data_cleaner-2.12.0-py3-none-any.whl Python 3 none any Details for universal_data_cleaner-2.12.0-py3-none-any.whl

Total release size: 215.7 kB

Release files / universal_data_cleaner-2.12.0.tar.gz

Download URL universal_data_cleaner-2.12.0.tar.gz
Size 120.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ed257aa4e7ba80b03b08e63b78a20362d40782fefa555d3e433d55d82e5829ec
BLAKE2b-256 checksum
How to use checksums
9e3302c2ca5e0d4a122decaa79b54b91f03881d82fa0d2a8ecd098df4149da89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / universal_data_cleaner-2.12.0-py3-none-any.whl

Download URL universal_data_cleaner-2.12.0-py3-none-any.whl
Size 95.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e71fe51d2b9270f2d6b1510be9be06321c71050fb9900ddab2e54230f9e572a
BLAKE2b-256 checksum
How to use checksums
89ce565978e4de8260a605205547d585b450547a8bd5fde225530aedbc06e8ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for universal-data-cleaner 2.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for universal_data_cleaner-2.12.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page