Pandera is a Python library for validating dataframe-like data with expressive schemas. It targets scientists, engineers, and analysts who want runtime and test-time checks on tabular data.
Overview
Pandera provides a flexible API to define and enforce schemas on dataframe-like objects from several Python dataframe libraries. The goal is to make data processing pipelines more readable and robust through typed, validated data structures.
You can validate data with object-based or class-based schema APIs, attach checks to functions that produce dataframes, and parse unstructured inputs into typed columns. Schemas can describe column types, allowed values, ranges, and custom validation rules, with optional coercion.
The library supports multiple dataframe backends, including pandas, polars, and pyspark, installed via optional extras. It integrates with the Python ecosystem for unit testing, including property-based testing of transformation functions against input and output schemas.
You can bootstrap schemas by inferring structure from clean data and refine them over time. Documentation covers pipeline checkpoints, custom checks, and generating test data to validate functions that produce datasets.
Key features
- Schema models for dataframe columns
- Runtime validation decorators
- Multi-backend dataframe support
- Custom and built-in field checks
- Schema inference from sample data
- Lazy validation reporting
- Hypothesis-friendly test strategies
- Parse and validate unstructured fields
Use cases
- Validate pandas pipelines at runtime
- Test data transformation functions in CI
- Define contracts for ML input data
- Catch bad database extracts early
- Document expected dataframe shapes