Spec-Zone.ru › Polars

polars.Series.zip_with

Series.zip_with(
    mask: Series,
    other: Series,
) → Self

Выбирает значения из self или other на основе заданной маски.

Если значение маски истинно, выбираются значения из self. Если значение маски ложно, выбираются значения из other.

Параметры:
mask

Булева серия.

other

Серия того же типа.

Возвращает:
Series

Примеры

>>> s1 = pl.Series([1, 2, 3, 4, 5])
>>> s2 = pl.Series([5, 4, 3, 2, 1])
>>> s1.zip_with(s1 < s2, s2)
shape: (5,)
Series: '' [i64]
[
    1
    2
    3
    2
    1
]
>>> mask = pl.Series([True, False, True, False, True])
>>> s1.zip_with(mask, s2)
shape: (5,)
Series: '' [i64]
[
    1
    4
    3
    2
    5
]

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

Spec-Zone.ru

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