Skip to content

Get the last n rows.

Source code

Description

Get the last n rows.

Usage

<LazyFrame>$tail(n = 5L)

Arguments

n Number of rows to return.

Value

A new LazyFrame object with applied filter.

See Also

<LazyFrame>$head()

Examples

library("polars")

lf = pl$LazyFrame(a = 1:6, b = 7:12)

lf$tail()$collect()
#> shape: (5, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ i32 ┆ i32 │
#> ╞═════╪═════╡
#> │ 2   ┆ 8   │
#> │ 3   ┆ 9   │
#> │ 4   ┆ 10  │
#> │ 5   ┆ 11  │
#> │ 6   ┆ 12  │
#> └─────┴─────┘
lf$tail(2)$collect()
#> shape: (2, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ i32 ┆ i32 │
#> ╞═════╪═════╡
#> │ 5   ┆ 11  │
#> │ 6   ┆ 12  │
#> └─────┴─────┘