API Reference

pandera

Statistical data validation library for pandas that checks dataframe schemas, column types, and value constraints.

Official Documentation ↗
CompatibilityThis documentation covers version v0.20. Check the official docs for the latest API surface.

Installation

pippip install pandera

Methods

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.

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.