Spec-Zone.ru › Polars

polars.Series.is_in

Series.is_in(
    other: Series | Collection[Any],
    *,
    nulls_equal: bool = False,
) → Series

Проверяет, содержатся ли элементы этой Series в другой Series.

Параметры:
other

Series или коллекция для поиска.

nulls_equalbool, default False

Если True, считать null отдельным значением. Значения null не будут распространяться.

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

Series с типом данных Boolean.

Примеры

>>> s = pl.Series("a", [1, 2, 3])
>>> s2 = pl.Series("b", [2, 4, None])
>>> s2.is_in(s)
shape: (3,)
Series: 'b' [bool]
[
    true
    false
    null
]
>>> # when nulls_equal=True, None is treated as a distinct value
>>> s2.is_in(s, nulls_equal=True)
shape: (3,)
Series: 'b' [bool]
[
    true
    false
    false
]
>>> # check if some values are a member of sublists
>>> sets = pl.Series("sets", [[1, 2, 3], [1, 2], [9, 10]])
>>> optional_members = pl.Series("optional_members", [1, 2, 3])
>>> print(sets)
shape: (3,)
Series: 'sets' [list[i64]]
[
    [1, 2, 3]
    [1, 2]
    [9, 10]
]
>>> print(optional_members)
shape: (3,)
Series: 'optional_members' [i64]
[
    1
    2
    3
]
>>> optional_members.is_in(sets)
shape: (3,)
Series: 'optional_members' [bool]
[
    true
    true
    false
]

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

Spec-Zone.ru

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