Spec-Zone.ru › Polars

polars.Series.cast

Series.cast(
    dtype: type[int | float | str_ | bool] | PolarsDataType,
    *,
    strict: bool = True,
    wrap_numerical: bool = False,
) → Self

Cast between data types.

Parameters:
dtype

DataType to cast to.

strict

If True invalid casts generate exceptions instead of nulls.

wrap_numerical

If True numeric casts wrap overflowing values instead of marking the cast as invalid.

Examples

>>> s = pl.Series("a", [True, False, True])
>>> s
shape: (3,)
Series: 'a' [bool]
[
    true
    false
    true
]
>>> s.cast(pl.UInt32)
shape: (3,)
Series: 'a' [u32]
[
    1
    0
    1
]

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

Spec-Zone.ru

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