Spec-Zone.ru › Polars

polars.Series.reinterpret

Series.reinterpret(
    *,
    signed: bool | None = None,
    dtype: type[int | float] | PolarsDataType | None = None,
) → Series

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 signed or dtype can be specified. Defaults to signed=True otherwise.

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
]

© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.reinterpret.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API