The Open-source Framework for Dataset Validation
📊 🔎 ✅
Data validation for scientists, engineers, and analysts seeking correctness.
Pandera is a Union.ai open source project that provides a flexible and expressive API for performing data validation on dataframe-like objects. The goal of Pandera is to make data processing pipelines more readable and robust with statistically typed dataframes.
Install
Pandera supports multiple dataframe libraries, including pandas, polars, pyspark, and more. To validate pandas DataFrames, install Pandera with the pandas extra:
With pip:
pip install 'pandera[pandas]'
With uv:
uv pip install 'pandera[pandas]'
With conda:
conda install -c conda-forge pandera-pandas
Get started
First, create a dataframe:
import pandas as pd
import pandera.pandas as pa
# data to validate
df = pd.DataFrame({
"column1": [1, 2, 3],
"column2": [1.1, 1.2, 1.3],
"column3": ["a", "b", "c"],
})
Validate the data using the object-based API:
# define a schema
schema = pa.DataFrameSchema({
"column1": pa.Column(int, pa.Check.ge(0)),
"column2": pa.Column(float, pa.Check.lt(10)),
"column3": pa.Column(
str,
[
pa.Check.isin([*"abc"]),
pa.Check(lambda series: series.str.len() == 1),
]
),
})
print(schema.validate(df))
# column1 column2 column3
# 0 1 1.1 a
# 1 2 1.2 b
# 2 3 1.3 c
Or validate the data using the class-based API:
# define a schema
class Schema(pa.DataFrameModel):
column1: int = pa.Field(ge=0)
column2: float = pa.Field(lt=10)
column3: str = pa.Field(isin=[*"abc"])
@pa.check("column3")
def custom_check(cls, series: pd.Series) -> pd.Series:
return series.str.len() == 1
print(Schema.validate(df))
# column1 column2 column3
# 0 1 1.1 a
# 1 2 1.2 b
# 2 3 1.3 c
Parse and validate unstructured data
Pandera can derive a column from the rest of the dataframe, so a schema both
parses and validates your data. Declare the derivation on the column itself
with ParsedField
/ ParsedColumn,
and the decisions API
to fill typed columns from unstructured text by asking a decision model:
import pandera.decisions as decisions
class Tickets(pa.DataFrameModel):
body: str
n_words: int = pa.ParsedField(
parser=lambda s: s.str.split().str.len(),
source="body",
)
department: Department = pa.ParsedField(
description="Which team should handle this ticket",
parser=decisions.Choice(),
)
class Config:
parser_source = "body"
# configure a provider (MockProvider is deterministic and free; swap in a
# real model like TypeSafe Jev or an Ollaya model as a runtime setting)
with decisions.provider(decisions.MockProvider(seed=7)):
Tickets.validate(df)
See the decision parsing tutorial to get started.
Next steps
See the official documentation to learn more.
Metadata
Release files for pandera 0.36.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pandera-0.36.0.tar.gz | 1.2 MB | Without provenance | Details for pandera-0.36.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandera-0.36.0-py3-none-any.whl | Python 3 | none | any | Details for pandera-0.36.0-py3-none-any.whl |
Total release size: 1.8 MB
Release files / pandera-0.36.0.tar.gz
| Download URL | pandera-0.36.0.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70194c6c9c8e3e950d62d9018d1fa6ba2b4371d1abc62c124574173f71432d80
|
|
BLAKE2b-256 checksum How to use checksums |
67ca452239887ed5435116f91e089e182501c59604007a12954131d7d508df10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pandera-0.36.0-py3-none-any.whl
| Download URL | pandera-0.36.0-py3-none-any.whl |
|---|---|
| Size | 604.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9ed1191fde25467813cde0ab3f279707c6e05fbb6c61649cfc5b646d1b2a783
|
|
BLAKE2b-256 checksum How to use checksums |
41d32719e0a0504c94ddd91e568632340a1941ac8f3b2be409aa30b28df9efe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for pandera 0.36.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.