polars.Series.bin.reinterpret#
- Series.bin.reinterpret(
- *,
- dtype: PolarsDataType,
- endianness: Endianness = 'little',
Interpret bytes as another type.
Supported types are numerical or temporal dtypes, or an
Array
of these dtypes.- Parameters:
- dtypePolarsDataType
Which type to interpret binary column into.
- endianness{“big”, “little”}, optional
Which endianness to use when interpreting bytes, by default “little”.
- Returns:
- Series
Series of data type
dtype
. Note that rows of the binary array where the length does not match the size in bytes of the output array (number of items * byte size of item) will become NULL.
Examples
>>> s = pl.Series("data", [b"\x05\x00\x00\x00", b"\x10\x00\x01\x00"]) >>> s.bin.reinterpret(dtype=pl.Int32, endianness="little") shape: (2,) Series: 'data' [i32] [ 5 65552 ]