Skip to content

Select the first column in the current scope

Description

Select the first column in the current scope

Usage

cs__first()

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