Skip to main content

Diff two dataset files: schema changes plus column-level distribution drift.

Project description

dsdiff

CI PyPI Python License: MIT

A git-style diff between two dataset files: schema changes and column-level distribution drift, with a CI gate.

When a dataset is regenerated, columns quietly get renamed, retyped, gain nulls, or shift distribution, and the pipeline keeps running while the model degrades. There is no quick "git diff for data" a reviewer can read on a pull request. dsdiff is that: point it at two files and it reports what changed, ranked by how much it should worry you.

$ dsdiff diff yesterday.parquet today.parquet
severity  column      change         detail
high      income      drift          PSI 0.412
high      signup_date column_added   new column
medium    age          null_rate      null rate 0.0% -> 7.3%
low       country      cardinality    distinct values 41 -> 44

Install

$ pip install dsdiff                 # from PyPI, once released
$ pip install git+https://github.com/jmweb-org/dsdiff   # latest, available now

Reads CSV, Parquet and JSON Lines through polars. No services, no schema files to author.

Usage

$ dsdiff diff a.csv b.csv            # human-readable table
$ dsdiff diff a.csv b.csv --json     # machine-readable findings
$ dsdiff diff a.csv b.csv --markdown # a table to paste into a PR
$ dsdiff diff a.csv b.csv --check    # exit non-zero on a high-severity change

Commit a baseline

Profile a dataset once and compare future data against the saved profile, without re-reading the original file:

$ dsdiff profile reference.parquet -o baseline.json
$ dsdiff diff baseline.json new_batch.parquet --check

The baseline stores the bin edges, so drift on new_batch is measured against exactly the same buckets as the reference.

In CI

- run: dsdiff diff baseline.json data/current.parquet --check

What it checks

  • Schema: columns added, removed, or retyped (all high severity).
  • Nulls: a jump in the null rate of a shared column.
  • Cardinality: a categorical column gaining or losing distinct values.
  • Distribution drift: the population stability index (PSI) per column, numeric columns binned by quantiles and categoricals by frequency.

Severity and the PSI scale

PSI is the standard tabular drift measure. The conventional reading is used here: below 0.1 is low (no meaningful shift), 0.1 to 0.25 is medium, and 0.25 or above is high. Schema and type changes are always high. By default --check fails only on high-severity findings; pass --fail-on medium to tighten the gate.

Exit codes

Code Meaning
0 Ran; no blocking finding (or --check not set)
1 --check found a finding at or above the fail threshold
2 A file was missing or in an unsupported format

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsdiff-0.2.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsdiff-0.2.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file dsdiff-0.2.0.tar.gz.

File metadata

  • Download URL: dsdiff-0.2.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dsdiff-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5bdf708c9209c879c9d565c6f9dcb05b84b3199760346c33e1460160e3fa373d
MD5 a5153ee5daf0fd6be335376904b12dd5
BLAKE2b-256 9bf5bd06ff92300d0c514142b287d664f987aa1e6323c43f61511ee8c05545a1

See more details on using hashes here.

File details

Details for the file dsdiff-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dsdiff-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dsdiff-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab0eef8ac5e7cfb687d303241bd14a3d93c374a67a5a3b7544e1e02c57483c36
MD5 7348a93c321d59dedaca688be3ddaebe
BLAKE2b-256 e4dccac8fb24abf7693e68f8de3823cd2bc83fb775a04c39f0f46a601f34b154

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page