Back to rankings

unionai-oss/pandera

Pythonunion.ai/pandera

A light-weight, flexible, and expressive statistical data testing library

pandasvalidationschemadataframestestingpandas-validationpandas-dataframedata-validationdata-cleaningdata-checktesting-toolsassertions
Star Growth
Stars
4.4k
Forks
421
Weekly Growth
Issues
394
2k4k
Nov 2018May 2021Dec 2023Jul 2026
ArtifactsPyPIpip install pandera
README

The Open-source Framework for Dataset Validation

📊 🔎 ✅

Data validation for scientists, engineers, and analysts seeking correctness.


CI Build Documentation Status PyPI version shields.io PyPI license pyOpenSci Project Status: Active – The project has reached a stable, usable state and is being actively developed. Documentation Status codecov PyPI pyversions DOI asv Total Downloads Conda Downloads Slack

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

[!WARNING] Pandera v0.24.0 introduces the pandera.pandas module, which is now the (highly) recommended way of defining DataFrameSchemas and DataFrameModels for pandas data structures like DataFrames. Defining a dataframe schema from the top-level pandera module will produce a FutureWarning:

import pandera as pa

schema = pa.DataFrameSchema({"col": pa.Column(str)})

Update your import to:

import pandera.pandas as pa

And all of the rest of your pandera code should work. Using the top-level pandera module to access DataFrameSchema and the other pandera classes or functions will be deprecated in version 0.29.0

Next steps

See the official documentation to learn more.

Related repositories
Asabeneh/30-Days-Of-Python

The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw

PythonPyPI30-days-of-pythonpython
68.8k12.8k
jakevdp/PythonDataScienceHandbook

Python Data Science Handbook: full text in Jupyter Notebooks

Jupyter NotebookMIT Licensescikit-learnnumpy
jakevdp.github.io/PythonDataScienceHandbook
49.3k19.1k
pandas-dev/pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more

PythonPyPIBSD 3-Clause "New" or "Revised" Licensedata-analysispandas
pandas.pydata.org
49.3k20.2k
microsoft/Data-Science-For-Beginners

10 Weeks, 20 Lessons, Data Science for All!

Jupyter NotebookMIT Licensedata-sciencepython
36.3k7.3k
tqdm/tqdm

:zap: A Fast, Extensible Progress Bar for Python and CLI

PythonPyPIOtherprogressbarprogressmeter
tqdm.github.io
31.2k1.5k
donnemartin/data-science-ipython-notebooks

Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.

PythonPyPIOtherpythonmachine-learning
29.3k8k
ranaroussi/yfinance

Download market data from Yahoo! Finance's API

PythonPyPIApache License 2.0pythonpandas
ranaroussi.github.io/yfinance
24.8k3.4k
sinaptik-ai/pandas-ai

Chat with your database or your datalake (SQL, CSV, parquet). PandasAI makes data analysis conversational using LLMs and RAG.

PythonPyPIOtherllmpandas
pandas-ai.com
23.7k2.3k
huggingface/datasets

🤗 The largest hub of ready-to-use datasets for AI models with fast, easy-to-use and efficient data manipulation tools

PythonPyPIApache License 2.0nlpdatasets
huggingface.co/docs/datasets
21.7k3.3k
bbfamily/abu

阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构

PythonPyPIGNU General Public License v3.0quanttrade
abuquant.com
17.9k4.6k
Kanaries/pygwalker

PyGWalker: Turn your dataframe into an interactive UI for visual analysis

PythonPyPIApache License 2.0data-analysispandas
kanaries.net/pygwalker
15.9k882
waditu/tushare

TuShare is a utility for crawling historical data of China stocks

PythonPyPIBSD 3-Clause "New" or "Revised" Licensepythonfinance
15.3k4.4k