Skip to main content

Ergonomic inline validation for Polars DataFrames with pipeable assertions and user-friendly wrappers around native Polars boolean expressions.

Project description

checkpl

Ergonomic inline validation for Polars DataFrames.

Installation

pip install checkpl

Quick Start

import polars as pl
from checkpl import verify, is_uniq

df = pl.DataFrame({
    "id": [1, 2, 3],
    "city": ["NYC", "LA", "NYC"],
    "year": [2020, 2020, 2021]
})

# Validate with Polars expressions
df.pipe(verify(pl.col("year") >= 2020))

# Validate uniqueness
df.pipe(verify(is_uniq("id")))

# Composite key uniqueness
df.pipe(verify(is_uniq("city", "year")))

# Chain validations
(
    df
    .pipe(verify(pl.col("year") >= 2020))
    .pipe(verify(is_uniq("id")))
    .filter(pl.col("city") == "NYC")
)

Features

  • Pipeable: Integrates with Polars' .pipe() for fluent data pipelines
  • Native expressions: Use any Polars boolean expression directly
  • Predicates: Built-in checks like is_uniq() for common validations
  • Clear errors: CheckError with descriptive messages and failure counts
  • LazyFrame support: Works with both DataFrame and LazyFrame

API

verify(check)

Validate a DataFrame using a Polars expression or predicate.

# With Polars expression
df.pipe(verify(pl.col("price") > 0))

# With predicate
df.pipe(verify(is_uniq("id")))

Raises CheckError if validation fails, returns DataFrame unchanged if valid.

is_uniq(*cols)

Check that column(s) have no duplicate values.

df.pipe(verify(is_uniq("id")))           # Single column
df.pipe(verify(is_uniq("id", "year")))   # Composite key

Error Handling

from checkpl import CheckError

try:
    df.pipe(verify(is_uniq("id")))
except CheckError as e:
    print(f"Check '{e.check_name}' failed: {e}")

License

MIT

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

checkpl-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

checkpl-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file checkpl-0.1.1.tar.gz.

File metadata

  • Download URL: checkpl-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for checkpl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 15ba2c7ffbf11f7891e3cf244f8de78c74ba89f0d3311a049113f550f43c7109
MD5 2835c0f98166e2267fc4ad62992fda8b
BLAKE2b-256 c83ba3a5dcc386c575beac92c1bfceb55819533f06f7a07e44fe2660d697f5c3

See more details on using hashes here.

File details

Details for the file checkpl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: checkpl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for checkpl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35e49a659e4729428b6fb30d344ef45dfa6b68da39452732513c7f11b3d62395
MD5 f1f4a12364f31f42af9206d9d4ce9259
BLAKE2b-256 50a70b18aaf55bc561b3bb9f43e9cc39669d15bde120e87f0cc67118fe4fb900

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