I would like to have same sort of Python type hinting on Polars DataFrame. Since DataFrame is not a generic type, I cannot do DataFrame[MyFrameSchema].
For example:
MyFrameSchema = {'price': float, 'quantity': int, 'product_name': str}
or:
class MyDataFrame(pl.DataFrame)
...
I now Polars has type SchemaDict in DataFrame constructor from polars.type_aliases import SchemaDict, but I don't know how to use it in Python code.
Maybe someone has idea how to wrap DataFrame into TMyDataFrame
Something like TMyDataFrame: TypeAlias = ... or something else. I am open for suggestions.
There are two Polars DataFrame validators that I know of, pandera (https://github.com/unionai-oss/pandera) and patito (https://github.com/JakobGM/patito). However, these do runtime validation and aren't really type hints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With