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:
CheckErrorwith descriptive messages and failure counts - LazyFrame support: Works with both
DataFrameandLazyFrame
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkpl-0.1.0.tar.gz.
File metadata
- Download URL: checkpl-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f01966939e01f5d7bf57a39b847f0c74395facf6450590e6effedbe9cb1f61c3
|
|
| MD5 |
edab4f076176484ea16a3b6cd5d7d35f
|
|
| BLAKE2b-256 |
309f0515b19bf86a7f993b50982a1175812178626caaeacc3bcb3a6c5c058fa7
|
File details
Details for the file checkpl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: checkpl-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a77be42341976860e6dd0ee8237d710a3257d734496cde4c3bb19f177a851ba0
|
|
| MD5 |
ebcd96cfbf73933fc23516b5f19d88be
|
|
| BLAKE2b-256 |
e633a3b4063c161bf41232525ce5d338c597842ad0cbc22a993cdad0e13de49c
|