patito.Model.valid_dtypes

property Model.valid_dtypes: dict[str, List[pl.PolarsDataType | pl.List]]

Return a list of polars dtypes which Patito considers valid for each field.

The first item of each list is the default dtype chosen by Patito.

Returns:

A dictionary mapping each column string name to a list of valid dtypes.

Raises:

NotImplementedError – If one or more model fields are annotated with types not compatible with polars.

Example

>>> from pprint import pprint
>>> import patito as pt
>>> class MyModel(pt.Model):
...     bool_column: bool
...     str_column: str
...     int_column: int
...     float_column: float
...
>>> pprint(MyModel.valid_dtypes)
{'bool_column': [Boolean],
 'float_column': [Float64, Float32],
 'int_column': [Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16, UInt8],
 'str_column': [Utf8]}