Get the last value.
Description
This function has different behavior depending on the input type:
- Missing -\> Takes last column of a context.
-
Character vectors -\> Syntactic sugar for
pl$col(…)$last()
.
Usage
pl$last(...)
Arguments
…
|
Characters indicating the column names (passed to pl$col() ,
see ?pl_col for details), or empty. If empty (default),
returns an expression to take the last column of the context instead.
|
Value
Expr
See Also
-
\
$last()
Examples
library("polars")
df = pl$DataFrame(
a = c(1, 8, 3),
b = c(4, 5, 2),
c = c("foo", "bar", "baz")
)
df$select(pl$last())
#> shape: (3, 1)
#> ┌─────┐
#> │ c │
#> │ --- │
#> │ str │
#> ╞═════╡
#> │ foo │
#> │ bar │
#> │ baz │
#> └─────┘
#> shape: (1, 1)
#> ┌─────┐
#> │ a │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 3.0 │
#> └─────┘
#> shape: (1, 2)
#> ┌─────┬─────┐
#> │ b ┆ c │
#> │ --- ┆ --- │
#> │ f64 ┆ str │
#> ╞═════╪═════╡
#> │ 2.0 ┆ baz │
#> └─────┴─────┘