Skip to main content

Lightweight, readable, and extensible validation for pandas DataFrames.

Project description

Project Logo

codecov Documentation Status

Lightweight, flexible, and intuitive validation for pandas DataFrames.
Define expectations for your data, validate them cleanly, and surface friendly errors or warnings — no configuration files, ever.

🔗 View full documentation →


📦 Installation

pip install framecheck

Try FrameCheck

Open In Colab

Try FrameCheck without installing anything - click the badge above to run an interactive demo notebook in Google Colab.


Main Features

  • Designed for pandas users
  • Simple, fluent API
  • Supports error or warning-level assertions
  • Validates both column-level and DataFrame-level rules
  • No config files, decorators, or boilerplate

Why Should You Validate Your Data Explicitly?

Because during a routine update, a typo like this:

SELECT u.credit_score AS age
FROM users u
JOIN profiles p ON u.id = p.user_id

...fails silently.

Now your age column has values in the 700s.

Your SQL doesn't error, your model still runs — and makes terrible predictions.


🔥 Example: Catch Bad Model Output Before It Hits Production

import pandas as pd
from framecheck import FrameCheck

df = pd.DataFrame({
    'transaction_id': ['TXN1001', 'TXN1002', 'TXN1003'],
    'user_id': [501, 502, 503],
    'transaction_time': ['2024-04-15 08:23:11', '2024-04-15 08:45:22', '2024-04-15 09:01:37'],
    'model_score': [0.03, 0.92, 0.95],
    'model_version': ['v2.1.0', 'v2.1.0', 'v2.1.0'],
    'flagged_for_review': [False, True, False]
})

schema = (
    FrameCheck()
    .column('transaction_id', type='string', regex=r'^TXN\d{4,}$')
    .column('user_id', type='int', min=1)
    .column('transaction_time', type='datetime', before='now')
    .column('model_score', type='float', min=0.0, max=1.0)
    .column('model_score', type='float', not_in_set=[0.0], warn_only=True)
    .column('model_version', type='string')
    .column('flagged_for_review', type='bool')
    .custom_check(
        lambda row: row['model_score'] <= 0.9 or row['flagged_for_review'] is True,
        "flagged_for_review must be True when model_score > 0.9"
    )
    .not_null()
    .not_empty()
    .only_defined_columns()
)

result = schema.validate(df)

if not result.is_valid:
    print(result.summary())

Output:

Validation FAILED
1 error(s), 1 warning(s)
Errors:
  - flagged_for_review must be True when model_score > 0.9 (failed on 1 row(s))
Warnings:
  - Column 'model_score' contains disallowed values: [0.0].

Identify Problem Records

invalid_rows = result.get_invalid_rows(df, include_warnings = True)
transaction_id user_id transaction_time model_score model_version flagged_for_review
TXN1003 503 2024-04-15 09:01:37 0.95 v2.1.0 False

📊 Comparison with Other Tools

FrameCheck is designed to be concise and pandas-native. For full comparisons with other packages:


License

MIT


Contact

LinkedIn Badge

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

framecheck-0.4.3.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

framecheck-0.4.3-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file framecheck-0.4.3.tar.gz.

File metadata

  • Download URL: framecheck-0.4.3.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for framecheck-0.4.3.tar.gz
Algorithm Hash digest
SHA256 44c0a80c1e9aa9a289b056fd9ea2631b7ee7c9f0ceec050baff068ce7324cb4a
MD5 8a5a5864831214c616c216bc9e2a1e63
BLAKE2b-256 2faadb4e6b8f8252457ee425c1e26f54480c827aeb51ae7cb8c1979ce7a7e576

See more details on using hashes here.

File details

Details for the file framecheck-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: framecheck-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for framecheck-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fb8a16c70350520dfe7121c9182cf75a0536c9731908a82262fd668d85d56db6
MD5 0fa1cbae540b1714e423d9cffc476600
BLAKE2b-256 f2aa300d7cb1025f3c1098089e2e21f0d745700022a2dbccb161ed1a8e94b11b

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