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

Uploaded Python 3

File details

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

File metadata

  • Download URL: diffolars-0.3.0.tar.gz
  • Upload date:
  • Size: 6.3 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.0.tar.gz
Algorithm Hash digest
SHA256 45b172dc80e5d306bc11cd37267ec3fb16cba1d260044db20d756c7c675366fc
MD5 c58e57ecc6de0e1e1a840ce0141fe013
BLAKE2b-256 c59b822062659f64b843ec7a3c62bab880bee6b263913f4b6ab742f43cdb9a81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffolars-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 442012750616ec2ae0d0cacd2bcd6cc286a59f343152b6a1fd5917d680327ae4
MD5 c919b7314505434502e54e979e490f6e
BLAKE2b-256 6f8db494a1b91ba239fa448afb95deb57629dbb6ee705f170455973cd2d23b23

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