polars.Series.reinterpret#
- Series.reinterpret( ) Series[source]#
Reinterpret the underlying bits as a signed/unsigned integer or float.
This operation is only allowed for numeric types of the same size. For lower bits numbers, you can safely use the cast operation.
Either
signedordtypecan be specified. Defaults tosigned=Trueotherwise.- Parameters:
- signed
If True, reinterpret as signed integer. Otherwise, reinterpret as unsigned integer.
- dtype
DataType to reinterpret to.
Examples
>>> s = pl.Series("a", [-(2**60), -2, 3]) >>> s shape: (3,) Series: 'a' [i64] [ -1152921504606846976 -2 3 ] >>> s.reinterpret(signed=False) shape: (3,) Series: 'a' [u64] [ 17293822569102704640 18446744073709551614 3 ] >>> s.reinterpret(dtype=pl.Int64) shape: (3,) Series: 'a' [i64] [ -1152921504606846976 -2 3 ]