Skip to main content

A generic dataframe validation library

Project description

checkedframe:

PyPI version PyPI - Downloads License: MIT Tests

Documentation

What is it?

checkedframe is a lightweight library for DataFrame validation built on top of narwhals.

Why use checkedframe?

Usage:

Installing

The easiest way is to install checkedframe is from PyPI using pip:

pip install checkedframe

Examples

import checkedframe as cf
import polars as pl
from checkedframe.polars import DataFrame


class AASchema(cf.Schema):
    reason_code = cf.String()
    reason_code_description = cf.String(nullable=True)
    shap = cf.Float64(cast=True)
    rank = cf.UInt8(cast=True)


    @cf.Check(column="reason_code")
    def check_reason_code_length(s: pl.Series) -> pl.Series:
        """Reason codes must be exactly 3 chars"""
        return s.str.len_bytes() == 3
    
    @cf.Check(column="reason_code")
    def check_is_id(s: pl.Series) -> bool:
        """Reason code must uniquely identify dataset"""
        return s.n_unique() == s.len()

    @cf.Check
    def check_row_height(df: pl.DataFrame) -> bool:
        """DataFrame must have 2 rows"""
        return df.height == 2



df = pl.DataFrame({
    "reason_code": ["abc", "abc", "o9"], 
    "reason_code_description": ["a desc here", "another desc", None],
    "shap": [1, 2, 3],
    "rank": [-1, 2, 1]
})

df: DataFrame[AASchema] = AASchema.validate(df)

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

checkedframe-0.0.5.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

checkedframe-0.0.5-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file checkedframe-0.0.5.tar.gz.

File metadata

  • Download URL: checkedframe-0.0.5.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for checkedframe-0.0.5.tar.gz
Algorithm Hash digest
SHA256 fecb7f57154a642403a974c12b061371073284c597bca15d55bff5d8a05120dc
MD5 6db9eab7326eea669e7bbc7a56a157f1
BLAKE2b-256 17a824faad9121b58a269df66eaa81bd87c8e6aa46274cf8d46f72b577224a4e

See more details on using hashes here.

File details

Details for the file checkedframe-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: checkedframe-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for checkedframe-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d36eccc3e45eb2cf3c35b78b658c73b7995b23913c9ed68dbb95ab3cd3b06626
MD5 8e4644e2f15d93d9abb001ee51627c30
BLAKE2b-256 d251a82bcbb09569e81ecc454ac9d821f759f00acdf88846f828589592ceb693

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