Skip to content

Check whether each value is the last occurrence

Source code

Description

Check whether each value is the last occurrence

Usage

<Expr>$is_last_distinct()

Value

Expr

Examples

library("polars")

as_polars_df(head(mtcars[, 1:2]))$
  with_columns(is_ulast = pl$col("mpg")$is_last_distinct())
#> shape: (6, 3)
#> ┌──────┬─────┬──────────┐
#> │ mpg  ┆ cyl ┆ is_ulast │
#> │ ---  ┆ --- ┆ ---      │
#> │ f64  ┆ f64 ┆ bool     │
#> ╞══════╪═════╪══════════╡
#> │ 21.0 ┆ 6.0 ┆ false    │
#> │ 21.0 ┆ 6.0 ┆ true     │
#> │ 22.8 ┆ 4.0 ┆ true     │
#> │ 21.4 ┆ 6.0 ┆ true     │
#> │ 18.7 ┆ 8.0 ┆ true     │
#> │ 18.1 ┆ 6.0 ┆ true     │
#> └──────┴─────┴──────────┘