Repository navigation
2.12.0 is the validation and statistical-drift release. It adds a composable rule layer on top of the existing validation report, reference-versus-current drift comparison, bounded failing-row diagnostics, and an append-only report sink for batch history.
Added
- Statistical drift:
DriftPolicy,DriftProfile,DistributionDriftReport, andcompare_distributions()compare a current batch against a stored reference using population stability index (PSI), an approximate 1-D Wasserstein distance plus a scale-free ratio, missingness deltas, and category share deltas. Levels outside the retained reference categories are aggregated into anotherbucket. Numeric and datetime columns are supported; booleans compare as categorical. - Documented thresholds: PSI
0.10warning /0.25error,5pp missingness warning,10pp category warning, an optional Wasserstein ratio threshold, andmin_sample=20, which downgrades errors to warnings on small batches. Thresholds must be finite and non-negative, counts must be integers, and policies serialize to and from JSON. - Portable profiles:
DriftProfile.from_frame()keeps a bounded, JSON-serializable summary (bin edges, shares, scales, 512 midpoint quantiles per numeric column, and the top 20 levels per categorical column) instead of a sorted raw column.to_json()/from_json()round-trip the profile and its policy, and the defaultrepris redacted. - Composable rules:
col()conditions with explicit.eq,.ne,.lt,.le,.gt,.ge,.isin,.not_in,.between,.isna,.notna, and.matchesmethods;&,|, and~composition;row_rule()for cross-column predicates;conditional()for scoped rules;grouped()for per-group checks;unique_combination(); andsum_equals(). Comparisons skip missing operands, so nulls do not fail a predicate unless it asks for them with.isna(). - Public
Validatableprotocol:validate()accepts expectations, rules, custom objects withname,column,severity, andcheck(frame), and mixed lists. A custom rule may return severalValidationResultobjects from one check. - Bounded diagnostics:
ValidationReport.diagnose(frame, limit=5, include_values=False, include_index=True, max_value_length=32)samples failing rows asRowDiagnostics— bounded per failing rule, value-free by default, truncated values when enabled, and only failing frame-level or grouped rules listed inskipped. - Batch history:
JsonlReportSinkappendsCleanerReport,DistributionDriftReport, or mapping records to a JSON Lines file, reads them back in order, summarizes history, and exposesdrift_against_previous(), which reuses the stored reference profile and policy for a reproducible comparison.
Changed
ValidationReportgainssourcesandfrom_results(..., sources=...)so diagnostics can attribute failures. Reports built from contract findings have no sources and produce an empty diagnostic sample.- JSON-safe conversion is shared by reporting, drift, and sinks; drift profiles and reports serialize NaN and infinity as
nulland leak no non-standard JSON literals. DriftProfilerequires a non-empty reference and current frame with unique string column labels, reports missing or kind-changed columns as errors with metrics skipped, and never mutates the caller's frames.sum_equals()fails rows with present non-numeric components or targets instead of silently skipping them, andJsonlReportSinkreads records withsplit("\n")so Unicode line separators in metadata cannot corrupt history.
Integration boundary
This release integrates with Pandera, Feature-engine, and Evidently rather than rebuilding them: rules and drift operate on plain pandas frames, so existing contract and monitoring stacks can keep their own semantics.
Documentation
- Statistical drift — policies, thresholds, profiles, sinks, and privacy notes.
- Validation, joins & dedup — rules, custom
Validatableobjects, and diagnostics. - API reference — full signatures.
Compatibility
Python 3.10–3.13, pandas 2.x and 3.x. No new runtime dependencies.
Full changelog: https://github.com/devlprkhan/universal-data-cleaner/blob/main/CHANGELOG.md