lector.types.cast#
Helpers to easily cast columns to their most appropriate/efficient type.
Classes#
Simple cast trying each registered type in order. |
|
Tries a specific cast for each column. |
|
Base class for autocasting implementations. |
Functions#
|
Turn a type conversion config into a list of converter instances. |
Attributes#
An (ordered) dict of converter class names and corresponding parameters. |
|
Accepted argument type where converters are expected. |
|
- class lector.types.cast.Autocast[source]#
Bases:
CastStrategySimple cast trying each registered type in order.
As a little performance optimization (having a huge effect on execution time), types are first tested on a sample for fast rejection of non-matching types.
- fallback: lector.types.abc.Converter | None[source]#
- class lector.types.cast.Cast[source]#
Tries a specific cast for each column.
- converters: dict[str, lector.types.abc.Converter][source]#
- class lector.types.cast.CastStrategy[source]#
Bases:
abc.ABCBase class for autocasting implementations.
- cast(data)[source]#
Shouldn’t be necessary, but @singledispatchmethod doesn’t work with inheritance.
- Parameters:
data (pyarrow.Array | pyarrow.ChunkedArray | pyarrow.Table) –
- Return type:
lector.types.abc.Conversion | pyarrow.Table
- lector.types.cast.ensure_converters(converters=None)[source]#
Turn a type conversion config into a list of converter instances.
- Parameters:
converters (Converters) –
- Return type: