Skip to content

Get the nth column(s) of the context

Description

Get the nth column(s) of the context

Usage

pl$nth(indices)

Arguments

indices One or more indices representing the columns to retrieve.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = c(1, 8, 3),
  b = c(4, 5, 2),
  c = c("foo", "bar", "baz")
)

df$select(pl$nth(1))
#> shape: (3, 1)
#> ┌─────┐
#> │ b   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 4.0 │
#> │ 5.0 │
#> │ 2.0 │
#> └─────┘
df$select(pl$nth(c(2, 0)))
#> shape: (3, 2)
#> ┌─────┬─────┐
#> │ c   ┆ a   │
#> │ --- ┆ --- │
#> │ str ┆ f64 │
#> ╞═════╪═════╡
#> │ foo ┆ 1.0 │
#> │ bar ┆ 8.0 │
#> │ baz ┆ 3.0 │
#> └─────┴─────┘