Get the index of the first occurrence of a value, or NA
if it’s not found
Description
Get the index of the first occurrence of a value, or NA
if
it’s not found
Usage
<Expr>$index_of(element)
Arguments
element
|
Value to find. |
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, NA, 17))
df$select(
seventeen = pl$col("a")$index_of(17),
null = pl$col("a")$index_of(NA),
fiftyfive = pl$col("a")$index_of(55),
)
#> shape: (1, 3)
#> ┌───────────┬──────┬───────────┐
#> │ seventeen ┆ null ┆ fiftyfive │
#> │ --- ┆ --- ┆ --- │
#> │ u32 ┆ u32 ┆ u32 │
#> ╞═══════════╪══════╪═══════════╡
#> │ 2 ┆ 1 ┆ null │
#> └───────────┴──────┴───────────┘