--- id: patito version: "0.8.6" license: MIT license_treatment: permissive maintenance: active --- # patito — A dataframe modelling library built on top of polars and pydantic. License: permissive · Maintenance: active · Downloads: 594.9K/mo ## 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 above — 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 pip install patito uv add patito 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_current - Install friction: low - Maintenance: active - Downloads: 594.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pydantic polars dataframe validation, type-annotated dataframe schema, dataframe validation with pydantic, generate test dataframes, polars dataframe type checking, schema validation for dataframes, mock dataframe generation, dataframe-validation, pydantic-integration, test-data-generation [View on SkillFed](https://skillfed.io/packages/patito) · [View on PyPI](https://pypi.org/project/patito/)