patito
A dataframe modelling library built on top of polars and pydantic.
What it is and what it does
Patito bridges pydantic and polars by letting you define dataframe schemas as type-annotated pydantic model subclasses. A single model class serves dual purpose: it defines the schema for polars DataFrames and represents individual rows as objects. This eliminates the need to maintain separate schema definitions and row representations.
The package provides three main capabilities: efficient dataframe validation with human-readable error messages, automatic generation of valid test data that respects all schema constraints, and utilities to work with dataframes in an object-oriented manner. You can validate incoming data, generate mock dataframes for tests without boilerplate, retrieve single rows as model instances, and apply schema-aware transformations. It is designed to work with polars but also supports pandas.
Use it for:
- Validate incoming dataframes against strict type and constraint rules before processing, catching schema violations early.
- Generate valid test dataframes that satisfy all model constraints without manually creating dummy data for each test.
- Retrieve and work with individual dataframe rows as typed model instances rather than raw dictionary-like objects.
- Enforce a single source of truth for data models across your codebase by using the same pydantic class for both validation and ORM-like access.
- Apply field-level constraints like uniqueness, bounds, regex patterns, and custom expressions to validate dataframe contents.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Patito combines pydantic models with polars DataFrames to provide type-annotated schema validation, test data generation, and object-oriented row access for dataframe operations.
Yes. Patito is actively maintained, has low install friction, carries no known vulnerabilities, and solves a real problem for teams using polars with pydantic. It's particularly valuable if you need strict dataframe validation and test data generation. The MIT license poses no restrictions. Start with it if your workflow involves both type-annotated models and polars dataframes.
Install
patito on PyPI
pip
pip install patitouv
uv add patitopoetry
poetry add patitoInstalling patito
Before you install
Low install friction with only three runtime dependencies (polars, pydantic, typing-extensions). The package is actively maintained with recent releases and 635 repository stars, indicating stable ongoing development.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install patito
import patito as pt
from typing import Literal
class Product(pt.Model):
product_id: int = pt.Field(unique=True)
temperature_zone: Literal["dry", "cold", "frozen"]
is_for_sale: bool
df = Product.examples({"is_for_sale": [True, False]})
Product.validate(df)
Requires Python 3.9 or later.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — polars, pydantic, typing-extensions |
| Maintenance | actively maintained — 191 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 594,946/month — #5,842 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: patito-0.8.6-py3-none-any.whl
Keywords: dataframe, validation
Tags
More Information Analysis packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyarrowpyarrow provides Python bindings to Apache…
permissive · top 100 on PyPI
networkxNetworkX provides data structures and…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
snowflake-snowpark-pythonSnowpark Python provides APIs to query and…
permissive · top 1,000 on PyPI
dataframelyDataframely validates the schema and content of…
unclear · top 15,000 on PyPI
polars-runtime-compatPolars-runtime-compat provides binary wheels…
permissive · top 15,000 on PyPI
polarsPolars is a DataFrame query engine written in…
permissive · top 1,000 on PyPI
grizzgrizz provides composable ingestors and…
permissive · top 15,000 on PyPI
polars-runtime-32Polars-runtime-32 is a compiled runtime…
permissive · top 1,000 on PyPI
polars-runtime-64A Rust-based analytical query engine for…
permissive · top 15,000 on PyPI
panderaPandera provides a flexible API for validating…
permissive · top 5,000 on PyPI
polars-dsPolars-ds adds data science and machine…
permissive · top 15,000 on PyPI
polars-hashPolars-hash adds cryptographic and…
unclear · top 15,000 on PyPI
polars-lts-cpupolars-lts-cpu is a CPU-optimized DataFrame…
permissive · top 15,000 on PyPI