Skip to main content

Build a column crosswalk between dataset versions by matching on column names and column contents.

Project description

field-match

Web app PyPI CI Docs License: MIT

Names, types, and values can all shift between data releases, quietly breaking anything downstream that assumes a stable schema. field-match builds a column crosswalk between two dataset versions: it compares every column pair on name and content, then reports which columns still match (verified), which appear renamed, which share a name but no longer match in content (suspect), and which were added or dropped.

The alternative is checking column by column, by hand and against documentation that may be buried. field-match makes that first pass in one call and flags what needs review.

Unlike other libraries in the data validation and data quality ecosystem, field-match builds the crosswalk itself rather than assuming you already have one. Some tools diff values once you know the mapping; others require you to write the mapping out as rules. field-match instead treats your last clean release as the reference and works the mapping out from name and content matching. It works across numeric, datetime, boolean, and text columns, reads CSV, Stata, SAS, and fixed-width files with no extra dependencies, plus Excel, Parquet, SPSS, and R via optional extras, and a browser-based version (no install) runs the same matching in-browser via Pyodide.

Developed for recurring public-interest data releases, where column drift is common.

No Python? Try the web app: https://cstirry.github.io/field-match/. Drop in two files, nothing to install.

Quick start

pip install field-match
from field_match import compare, read_table

new_data = read_table("survey_2022.xlsx")
report = compare("survey_2021.csv", new_data)
print(report)
  16  verified  column name and contents both match
  64  renamed   contents match, but under a different column name
   4  suspect   column name matches, but contents do not
  21  dropped   missing from the new dataset
  76  added     missing from the reference dataset

Review the proposed mapping, then apply it: df = report.apply(new_data). The reference can be a previous dataset, a list of expected column names, or a fitted sklearn model.

Full documentation: the report in depth, supported file formats, tuning, how matching works, and the API reference.

Examples with real data

Four scripts in examples/ download real government releases and crosswalk them to identify column drift:

  1. CDC/ATSDR Social Vulnerability Index (cdc_atsdr_svi.py, or as a notebook: cdc_atsdr_svi.ipynb / Colab): column name reused differently
  2. CDC 500 Cities/PLACES (cdc_places.py): column renames identified by content
  3. IMLS Public Libraries Survey (imls_pls.py): thirty years of column drift
  4. NAMCS (namcs_formats.py): SAS, Stata, and R datasets

Walkthroughs in the docs.

Development

See CONTRIBUTING.md for setup, tests, docs, and the release process.

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

field_match-0.4.0.tar.gz (85.2 kB view details)

Uploaded Source

Built Distribution

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

field_match-0.4.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: field_match-0.4.0.tar.gz
  • Upload date:
  • Size: 85.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for field_match-0.4.0.tar.gz
Algorithm Hash digest
SHA256 17ec61c3bf7d953f89928ecc9f52cc7478c6293e070d9308ef35adc15696c60e
MD5 0255ba0505121fb31f287b766fd430ac
BLAKE2b-256 466744bbd4b526cd2161f3da15e3e390ffb3335a7c9628e2c453ac65abf0a2f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for field_match-0.4.0.tar.gz:

Publisher: publish.yml on cstirry/field-match

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: field_match-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for field_match-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7795d5b1e03954e668838bf9760460b82442d647ad0d95afd815debd56eb4dd9
MD5 6c6c22ff05694a57e4ef77fcdb9d3b2c
BLAKE2b-256 5d2d6eec5c469063df7c6fb6b6b3852760e4f9d350decb3ddd650e894941a592

See more details on using hashes here.

Provenance

The following attestation bundles were made for field_match-0.4.0-py3-none-any.whl:

Publisher: publish.yml on cstirry/field-match

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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