Home
# pdschema
Validate pandas DataFrames against column contracts.
Types, nullability, and per-cell checks — no cleaning or transforms.
Column Contracts
Declare dtype, nullability, and per-column validators in a `Schema`.
Class-Based Schemas
Define columns as class attributes — inherit, compose, reuse.
Function Validation
`@pdfunction` checks DataFrame inputs and outputs at call time.
Extensible Validators
Subclass `Validator` or pass any `callable` that returns a bool.
Try it¶
pip install pdschema
import pandas as pd
from pdschema import Column, IsNonEmptyString, IsPositive, Range, Schema
df = pd.DataFrame({
"name": ["Alice", "Bob", "Charlie"],
"age": [25, 30, 35],
"score": [85.5, 92.0, 78.5],
})
schema = Schema([
Column("name", str, nullable=False, validators=[IsNonEmptyString()]),
Column("age", int, validators=[IsPositive()]),
Column("score", float, validators=[Range(0, 100)]),
])
schema.validate(df)
Guides¶
| Guide | What you learn |
|---|---|
| Quickstart | Define a schema, validate a DataFrame, read errors |
| Validators | Built-in checks and writing your own |
| Functions | Validate inputs and outputs with @pdfunction |