polars.ScanCastOptions#
- class polars.ScanCastOptions(
- *,
- integer_cast: Literal['upcast', 'forbid'] = 'forbid',
- float_cast: Literal['forbid'] | FloatCastOption | Collection[FloatCastOption] = 'forbid',
- datetime_cast: Literal['forbid'] | DatetimeCastOption | Collection[DatetimeCastOption] = 'forbid',
- missing_struct_fields: Literal['insert', 'raise'] = 'raise',
- extra_struct_fields: Literal['ignore', 'raise'] = 'raise',
- _internal_call: bool = False,
Options for scanning files.
- __init__(
- *,
- integer_cast: Literal['upcast', 'forbid'] = 'forbid',
- float_cast: Literal['forbid'] | FloatCastOption | Collection[FloatCastOption] = 'forbid',
- datetime_cast: Literal['forbid'] | DatetimeCastOption | Collection[DatetimeCastOption] = 'forbid',
- missing_struct_fields: Literal['insert', 'raise'] = 'raise',
- extra_struct_fields: Literal['ignore', 'raise'] = 'raise',
- _internal_call: bool = False,
Common configuration for scanning files.
Warning
This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.
- Parameters:
- integer_cast
Configuration for casting from integer types:
upcast
: Allow lossless casting to wider integer types.forbid
: Raises an error if dtypes do not match.
- float_cast
Configuration for casting from float types:
upcast
: Allow casting to higher precision float types.downcast
: Allow casting to lower precision float types.forbid
: Raises an error if dtypes do not match.
- datetime_cast
Configuration for casting from datetime types:
nanosecond-downcast
: Allow nanosecond precision datetime to be downcasted to any lower precision. This has a similar effect to PyArrow’scoerce_int96_timestamp_unit
.convert-timezone
: Allow casting to a different timezone.forbid
: Raises an error if dtypes do not match.
- missing_struct_fields
Configuration for behavior when struct fields defined in the schema are missing from the data:
insert
: Inserts the missing fields.raise
: Raises an error.
- extra_struct_fields
Configuration for behavior when extra struct fields outside of the defined schema are encountered in the data:
ignore
: Silently ignores.raise
: Raises an error.
Methods
__init__
(*[, integer_cast, float_cast, ...])Common configuration for scanning files.