Spec-Zone.ru › Polars

polars.Expr.get

Expr.get(
    index: int | Expr,
    *,
    null_on_oob: bool = False,
) → Expr

Return a single value by index.

engine:In MemoryPartially Streaming
Parameters:
index

An expression that evaluates to an integer. Negative indexing is supported (will block streaming).

null_on_oob

Behavior if an index is out of bounds:

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

Expression of the same data type.

Examples

>>> df = pl.DataFrame(
...     {
...         "group": [
...             "one",
...             "one",
...             "one",
...             "two",
...             "two",
...             "two",
...         ],
...         "value": [1, 98, 2, 3, 99, 4],
...     }
... )
>>> df.group_by("group", maintain_order=True).agg(pl.col("value").get(1))
shape: (2, 2)
┌───────┬───────┐
│ group ┆ value │
│ ---   ┆ ---   │
│ str   ┆ i64   │
╞═══════╪═══════╡
│ one   ┆ 98    │
│ two   ┆ 99    │
└───────┴───────┘

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

Spec-Zone.ru

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