Skip to content

Get the last n rows.

Source code

Description

This function is syntactic sugar for pl$col(…)$tail(n).

Usage

pl$tail(..., n = 10)

Arguments

Characters indicating the column names, passed to pl$col(). See ?pl_col for details.
n Number of rows to return.

Value

Expr

See Also

  • \$tail()

Examples

library("polars")

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

df$select(pl$tail("a"))
#> shape: (3, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> │ 8.0 │
#> │ 3.0 │
#> └─────┘
df$select(pl$tail("a", "b", n = 2))
#> shape: (2, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 8.0 ┆ 5.0 │
#> │ 3.0 ┆ 2.0 │
#> └─────┴─────┘