skillfed

patito

A dataframe modelling library built on top of polars and pydantic.

patito v0.8.6 594.9K downloads/30d#5,842 on PyPI635
Permissive license MIT Active released

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 patito

uv

uv add patito

poetry

poetry add patito

Installing 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

pydantic polars dataframe validationtype-annotated dataframe schemadataframe validation with pydanticgenerate test dataframespolars dataframe type checkingschema validation for dataframesmock dataframe generation
dataframe-validationpydantic-integrationtest-data-generation

More Information Analysis packages