Spec-Zone.ru › Polars

polars.Series.gather

Series.gather(
    indices: int | list_[int] | Expr | Series | np.ndarray[Any,
    Any],
    *,
    null_on_oob: bool = False,
) → Series

Выбрать значения по индексу.

Параметры:
indices

Положение индекса, используемое для выбора.

null_on_oob

Поведение, если индекс выходит за границы:

  • True -> установить для результата значение null
  • False -> вызвать ошибку

Примеры

>>> s = pl.Series("a", [1, 2, 3, 4])
>>> s.gather([1, 3])
shape: (2,)
Series: 'a' [i64]
[
    2
    4
]

Используйте null_on_oob=True, чтобы возвращать null для индексов, выходящих за границы.

>>> s.gather([1, 10], null_on_oob=True)
shape: (2,)
Series: 'a' [i64]
[
    2
    null
]

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

Spec-Zone.ru

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