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
Safe ingestion Contract-driven CSV and Excel reads with ingestion reports
Batch reporting CleanerReport and the data-cleaner audit CLI
Validation, joins & dedup Expectations, join diagnostics, integrity, 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
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, and IQR capping
  • 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 and Excel 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 and transform-time drift reports
  • expectation checks and validation reports
  • join diagnostics, referential integrity, and audited business-key dedup
  • train/test split audits for duplicate, group, temporal, and target leakage
  • joblib save / load, manifests, 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

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.9.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.9.0
File Size Uploaded Provenance Actions
universal_data_cleaner-2.9.0.tar.gz 80.1 kB Without provenance Details for universal_data_cleaner-2.9.0.tar.gz

Built distribution (wheel)

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

Total release size: 145.0 kB

Release files / universal_data_cleaner-2.9.0.tar.gz

Download URL universal_data_cleaner-2.9.0.tar.gz
Size 80.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fa091eaf4faabad70abb6fc66826ddddbf27337eaf14ff4f49d31d47fcd99370
BLAKE2b-256 checksum
How to use checksums
fdf86c403d4fb5a3beddd2780243c8b9c7d8cdf9457b5504f6f62b5d27b7bf94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}

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

Download URL universal_data_cleaner-2.9.0-py3-none-any.whl
Size 64.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d7d9761fca6291a99ea04c84db9231422739682ea363f4e36f5ea1f56e05ac1
BLAKE2b-256 checksum
How to use checksums
4a29f7f794bd1c7c8f8ec9af985e82bd881016062adb03ce5e2b756e956d67ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}

Security for universal-data-cleaner 2.9.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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