Return a single value by index
Description
Return a single value by index
Usage
<Expr>$get(index, ..., null_on_oob = FALSE)
Arguments
index
|
An expression that leads to a UInt32 dtyped Series. |
…
|
These dots are for future extensions and must be empty. |
null_on_oob
|
If TRUE, return null if an index is out of
bounds. Otherwise, raise an error.
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
group = c("one", "one", "one", "two", "two", "two"),
value = c(1, 98, 2, 3, 99, 4)
)
df$group_by("group", maintain_order = TRUE)$agg(
pl$col("value")$get(1)
)
#> shape: (2, 3)
#> ┌───────┬────────────────┬───────┐
#> │ group ┆ maintain_order ┆ value │
#> │ --- ┆ --- ┆ --- │
#> │ str ┆ bool ┆ f64 │
#> ╞═══════╪════════════════╪═══════╡
#> │ two ┆ true ┆ 99.0 │
#> │ one ┆ true ┆ 98.0 │
#> └───────┴────────────────┴───────┘