Skip to content

Select the last column in the current scope

Description

Select the last column in the current scope

Usage

cs__last()

Value

A Polars selector

See Also

cs for the documentation on operators supported by Polars selectors.

Examples

library("polars")

df <- pl$DataFrame(
  foo = c("x", "y"),
  bar = c(123L, 456L),
  baz = c(2.0, 5.5),
  zap = c(FALSE, TRUE)
)

# Select the last column:
df$select(cs$last())
#> shape: (2, 1)
#> ┌───────┐
#> │ zap   │
#> │ ---   │
#> │ bool  │
#> ╞═══════╡
#> │ false │
#> │ true  │
#> └───────┘
# Select everything except for the last column:
df$select(!cs$last())
#> shape: (2, 3)
#> ┌─────┬─────┬─────┐
#> │ foo ┆ bar ┆ baz │
#> │ --- ┆ --- ┆ --- │
#> │ str ┆ i32 ┆ f64 │
#> ╞═════╪═════╪═════╡
#> │ x   ┆ 123 ┆ 2.0 │
#> │ y   ┆ 456 ┆ 5.5 │
#> └─────┴─────┴─────┘