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

Take values by index.

Parameters:
indices

Index location used for selection.

null_on_oob

Behavior if an index is out of bounds:

  • True -> set the result to null
  • False -> raise an error

Examples

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

Use null_on_oob=True to return null for out-of-bounds indices.

>>> 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