Skip to main content

checkpl

Ergonomic inline validation for Polars DataFrames.

Installation

pip install checkpl

Quick Start

import polars as pl
from assert_polars 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 assert_polars import CheckError

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

License

MIT

Metadata

Release files for assert-polars 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for assert-polars 0.2
File Size Uploaded
assert_polars-0.2.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for assert-polars 0.2
File Interpreter ABI Platform
assert_polars-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / assert_polars-0.2.tar.gz

Download URL assert_polars-0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
499a617ae6c72b8511cca5c7c3ea77ae2838f2089c279497d71eddf08aae68db
BLAKE2b-256 checksum
How to use checksums
2dcf9eb34e3910fb230b64efbef68617d40dda1e3539b3d3f42334361dee5c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / assert_polars-0.2-py3-none-any.whl

Download URL assert_polars-0.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99abc7c349f6fba188ef6adabd3856cb32fd1e34308156c338ac9cb7de94ae64
BLAKE2b-256 checksum
How to use checksums
3df016c4f8cb2e485bc498dbfa4a88d45c178cfea3b96633504821d80b0851d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page