pandera
Statistical data validation library for pandas that checks dataframe schemas, column types, and value constraints.
Official Documentation ↗v0.20. Check the official docs for the latest API surface.Installation
pip install panderaMethods
No methods match this filter.
Overview
pandera is a statistical data validation library for pandas that checks dataframe schemas, column types, and value constraints. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
DataFrameSchema— Declares the columns, dtypes, and dataframe-level checks a table must satisfy.Column— Describes one column with its dtype and value-level checks.schema.validate— Validates a dataframe against the schema, raising on violations or collecting them lazily.
Example
import pandera as pa
import pandas as pd
schema = pa.DataFrameSchema({
"age": pa.Column(int, pa.Check.ge(0)),
})
df = schema.validate(pd.DataFrame({"age": [1, 2]}))
Notes
Validation can run eagerly or lazily; lazy mode is better for diagnosing bad batches because it reports all failures at once.
Verification
Validate a conforming dataframe successfully, then validate one violating a check and confirm validation fails.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://pandera.readthedocs.io/en/stable/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:35.988Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- Lazily Validate dataframes so that all validation rules are executed before raising an error. (https://pandera.readthedocs.io/en/stable/)
- An error argument can also be supplied to Check for custom error messages. (https://pandera.readthedocs.io/en/stable/)
- The error report groups DATA and SCHEMA errors to to give an overview of error sources within a dataframe. (https://pandera.readthedocs.io/en/stable/)
FAQ
- What does lazy validation do?
- It collects all failures into a SchemaErrors report instead of stopping at the first violation, useful for data profiling.
- How do I validate inside a function?
- Decorate the function with pa.check_types so its annotated inputs and outputs are validated automatically.
- How do I allow null values?
- Set nullable=True on the column, or add a Check that permits None depending on your business rules.
Report a problem with this API docOpens a pre-filled issue on GitHub.