Skip to main content

dazdiff

CI PyPI Python

dazdiff compares two tables value by value, from Python or from the command line. It is a small Python take on the R package pedrobtz/dazdiff. Documentation: https://pedrobtz.github.io/py-dazdiff/.

Its main function, diff_table(), answers one of two questions:

  • Does this table match the benchmark? (mode="benchmark", the default.) The benchmark's column types are the truth: the tested table is cast to them and its extra columns are dropped.
  • Are these two tables equal? (mode="equal".) Both tables must have the same columns with the same types; nothing is cast.

The result has one row per key and measure, with row_id_x, row_id_y, value_x, value_y, diff, abs_diff, rel_diff and a status of same, changed, only_x or only_y.

Installation

pip install dazdiff        # the library and the CLI
uv tool install dazdiff    # the CLI on its own

It needs Python 3.10 or later and pandas 2.2.2 or later. The development version installs from GitHub: pip install git+https://github.com/pedrobtz/py-dazdiff.

Command line

$ dazdiff examples/benchmark.csv examples/stored.csv --by id,region --only-diffs
dazdiff: Dropped column(s) of `y` that the benchmark `x` does not have: loaded_at.
 ID REGION metric  row_id_x  row_id_y  value_x  value_y  diff  abs_diff  rel_diff  status
  1  north  UNITS         1         1     10.0     10.4   0.4       0.4  0.038462 changed
  2  south AMOUNT         2         2    200.0    200.5   0.5       0.5  0.002494 changed
  4   west AMOUNT         4      <NA>    400.0      NaN   NaN       NaN       NaN  only_x
  ...
Option Meaning
-b, --by COLS comma-separated key columns (default: every non-measure column)
--exclude COLS comma-separated columns to leave out of both files
-m, --measures numeric (default), numeric+integer, or comma-separated names
--mode benchmark (default) or equal
-t, --tolerance absolute tolerance
-r, --rel-tol relative tolerance (relative to the larger magnitude)
--no-cast do not cast the second file to the first's types; they must agree
--no-truncate refuse casts that would truncate values to integers
--duplicates disambiguate repeated keys in arrival order (default), aggregate them as multisets, or error
--row-key position or sorted: add a row_number key when every column is a measure
--sep CSV separator
-o, --output FILE write the full comparison to a CSV file
-s, --summary print the per-measure summary instead
-R, --report print a text report; --x-name, --y-name label the files, --ascii avoids box-drawing characters
-e, --explain [COLUMN] print which key values split same from not same; with a column, per value of it
--joined with --explain, count only rows found in both files
-d, --only-diffs print only rows that are not same
-q, --quiet print nothing

The exit status is 0 when the tables match, 1 when they differ and 2 on error, so dazdiff works in scripts and CI. Column names are normalized (upper case, other characters turned into _), so id and ID pair up. Because CSV files carry no types, a column read as integer in one file and as decimals in the other is compared as float; one that is float only because of an empty value stays an integer.

python -m dazdiff works too.

Python

import pandas as pd
from dazdiff import diff_report, diff_summary, diff_table, is_matching

benchmark = pd.read_csv("examples/benchmark.csv")
stored = pd.read_csv("examples/stored.csv")

d = diff_table(benchmark, stored, by=["id", "region"], measures="numeric+integer")
d[d["status"] != "same"]
diff_summary(d)
assert not is_matching(d)  # rows 4 and 5 are each in one table only

is_matching(d, tolerance=1) judges the values again at another threshold, without running the comparison again.

diff_explain(d) says which key columns separate the rows that match from those that do not, and diff_explain(d, "region") counts each status per region, most differences first.

exclude= leaves technical columns (load stamps, run ids) out of both tables. When a number of the tested table is cast to the benchmark's text, it is written with the decimals the benchmark uses, so 2 meets "2.0".

With no measure columns, rows are compared as wholes, and a repeated row counts once per copy. Values truncated when casting to the benchmark's integer columns are recorded in d.attrs["truncated"].

Report

print(diff_report(d, "benchmark", "stored"))

draws the columns compared, how the rows of the two tables align, and per changed measure its match rate and largest differences. diff_report(d).format(unicode=False) draws it in ASCII.

In tests

from dazdiff import assert_table_equal

expected = pd.DataFrame({"id": [1, 2], "amount": [100.0, 200.0]})
actual = pd.DataFrame({"id": [1, 2], "amount": [100.0, 200.0 + 1e-12]})
assert_table_equal(actual, expected)  # within a relative 1.5e-8

assert_table_equal() tests actual against expected as the benchmark and raises AssertionError with diff_summary() and the first records that differ, so it works under pytest, unittest or a plain script. A repeated key is an error unless duplicates= says how to treat it.

Development

uv sync
uv run pytest

Metadata

Release files for dazdiff 0.1.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 dazdiff 0.1.0
File Size Uploaded Provenance Actions
dazdiff-0.1.0.tar.gz 52.3 kB With provenance Details for dazdiff-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dazdiff 0.1.0
File Interpreter ABI Platform Actions
dazdiff-0.1.0-py3-none-any.whl Python 3 none any Details for dazdiff-0.1.0-py3-none-any.whl

Total release size: 84.2 kB

Release files / dazdiff-0.1.0.tar.gz

Download URL dazdiff-0.1.0.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
29b6138bab18349baf891e02ba344582b70e32b385da075a1e614f0a58a05187
BLAKE2b-256 checksum
How to use checksums
ab907c4a6f44bed62934153e7db45cb4a9032c1b74cf5e43c514ddf9089639df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 19, 2026.

Transparency log

Release files / dazdiff-0.1.0-py3-none-any.whl

Download URL dazdiff-0.1.0-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
811c75f1fd4857743e110563386d2db6a225a3f5ffa0774c8fdd242e1f11543a
BLAKE2b-256 checksum
How to use checksums
98c8b08a1c84fa534a97e512ec7e677e7b2eedbd2000ff21d21b373fcf14a6aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 19, 2026.

Transparency log

Security for dazdiff 0.1.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 dazdiff-0.1.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 19, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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