Skip to main content

Yet another data diff

Project description

diffolars

A small Polars-based toolkit for comparing two versions of a dataframe and generating randomized test data to exercise that comparison.

Ideally used to compare dataloads in the day-to-day of a database analyst.

Installation

uv add diffolars

Generating test data

diffolars.demo generates a random dataframe and a mutated copy of it, useful for testing diff logic without hand-crafting fixtures.

from diffolars.demo import get_df_pair

pair = get_df_pair(
    n_rows=100,
    n_cols=10,
    n_new_rows=5,    # rows added in the mutated copy
    n_new_cols=2,    # columns added in the mutated copy
    coverage=0.1,    # fraction of existing cells randomly changed
    seed=42,
)

original = pair["original"]
mutated = pair["mutated"]

Every generated row gets a record_id UUID column, used to match rows between the original and mutated dataframes. get_random_data and get_mutated_data are also available individually if you want to generate or mutate a dataframe on its own.

Diffing

diffolars.diff provides the comparison API for two dataloads (e.g. a previous load vs. the latest load), and is under active development.

Inputs to these functions can be a list, polars.DataFrame, or polars.LazyFrame.

  • column_intercept / column_symmetric_diff — shared vs. exclusive columns between the two tables
  • row_intercept / row_symmetric_diff — shared vs. exclusive rows, based on a record ID column
  • prune_rows — returns the rows exclusive to each table (i.e. dropped by the join), tagged with which table they came from
  • report_prune — summarizes the pruned rows/columns as a single dict entry, suitable for logging
  • get_core — joins the two tables down to their shared rows and columns, for doing the field-to-field comparison

Currently only the Windows build is available.

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

diffolars-0.4.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

diffolars-0.4.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file diffolars-0.4.0.tar.gz.

File metadata

  • Download URL: diffolars-0.4.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for diffolars-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e8d60c21fcdf99d96bf63e0dcdef9072ed406cc0234103d67f9592dc863f59c9
MD5 15488f41dc6ca6c43854dd04285a0de7
BLAKE2b-256 36083f2410a65dc83cf88cfd24fe2d4366e59ffb4793643b643424e3a5e2eba5

See more details on using hashes here.

File details

Details for the file diffolars-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: diffolars-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for diffolars-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32195bf52ddb9239792271e5053dda3c6d267b3d6d401f5bba5e10f8e46371e9
MD5 1669c1401766a8b18a99a01d6b4df75a
BLAKE2b-256 e71c2055aeccd7dc2acface5cfe2a9a2b51de00193523853b58a051c8f2570ad

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