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.3.1.tar.gz (6.4 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.3.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: diffolars-0.3.1.tar.gz
  • Upload date:
  • Size: 6.4 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.3.1.tar.gz
Algorithm Hash digest
SHA256 dfdde8bdefdc3aa1b81c6903a3561bf8360b0808964522803b818fb9a290a93e
MD5 55abf7e3fb46b168509c3b434745c184
BLAKE2b-256 8836ed8aff1e5f4d1676b8113bb69e0853114a570cc8e1f431f2a6fe2c716e2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffolars-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 456516f64f42500ce4c3a3f4b86ee664fbb0f03006ff67bbc3363173dae5d080
MD5 df249fe0d5cc948d3995cde9e391917d
BLAKE2b-256 7846d17b44254a032437dfa84dd6785b4d80622375f04cd7d226f0b7fb85db33

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