{"id":24214,"library":"patito","title":"Patito","description":"Patito is a dataframe modelling library built on top of Polars and Pydantic, providing a declarative way to define schemas, validate data, and serialize dataframes. Version 0.8.6 requires Python >= 3.9 and polars >= 1.32.0. The library is actively maintained with frequent releases.","status":"active","version":"0.8.6","language":"python","source_language":"en","source_url":"https://github.com/JakobGM/patito","tags":["polars","pydantic","data-validation","dataframe","schema"],"install":[{"cmd":"pip install patito","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dataframe library; requires >= 0.20.10, but 0.8.5+ requires >=1.32.0","package":"polars","optional":false},{"reason":"Schema definition and validation; requires >= 2.7","package":"pydantic","optional":false}],"imports":[{"note":"Model is exported directly from the top-level package since v0.6.0","wrong":"from patito.models import Model","symbol":"Model","correct":"from patito import Model"},{"note":"Patito's DataFrame subclass is available at top-level since v0.7.0","wrong":"from patito.polars import DataFrame","symbol":"DataFrame","correct":"from patito import DataFrame"}],"quickstart":{"code":"import polars as pl\nfrom patito import Model, validate\n\nclass Product(Model):\n    product_id: int\n    name: str\n    price: float = 0.0\n    is_active: bool = True\n\n# Create a valid dataframe\ndf = pl.DataFrame({\n    \"product_id\": [1, 2, 3],\n    \"name\": [\"A\", \"B\", \"C\"],\n    \"price\": [10.0, 20.0, 30.0],\n})\n\n# Validate and cast\nvalidated = Product.validate(df)\nprint(validated)\n\n# Use patito's DataFrame type hint for type checking\nproducts: DataFrame[Product] = df","lang":"python","description":"Define a Pydantic model, create a Polars DataFrame, and validate it with patito."},"warnings":[{"fix":"Pin patito to <0.7.0 if you need polars 0.x or pydantic <2.7: pip install 'patito<0.7.0'","message":"Patito 0.7.0 dropped support for polars < 1.0 and pydantic < 2.7. If you are on older versions, do not upgrade.","severity":"breaking","affected_versions":"< 0.7.0"},{"fix":"Upgrade polars to match patito's requirement: pip install 'polars>=1.32.0'","message":"Patito 0.8.1+ requires polars >= 1.10.0, and 0.8.5+ requires >= 1.32.0. Existing code may break due to polars API changes.","severity":"breaking","affected_versions":">=0.8.1"},{"fix":"Use model_config = ConfigDict(extra='allow') instead of model_config = ConfigDict(allow_superfluous_columns=True).","message":"The ConfigDict key 'allow_superfluous_columns' is deprecated in favor of 'extra' since patito 0.8.4.","severity":"deprecated","affected_versions":">=0.8.4"},{"fix":"Add 'from __future__ import annotations' at the top of your module or use a string annotation: 'DataFrame[MyModel]'","message":"When using DataFrame[MyModel] as a type hint, patito's metaclass only works correctly if the module uses from __future__ import annotations or if the hint is inside a function/class that is evaluated at runtime. Otherwise, you may get a generic DataFrame without schema enforcement.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install pydantic'","cause":"Pydantic is a required dependency but not installed automatically in all environments (e.g., when using pip with --no-deps).","error":"ModuleNotFoundError: No module named 'pydantic'"},{"fix":"Ensure data in each column can be cast to the model's field type, or use null values for missing data.","cause":"Patito's validate() casts columns to the types defined in the model; if a column contains incompatible values (e.g., string in an int field), validation fails.","error":"polars.exceptions.ComputeError: ... dtype mismatch"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}