Skip to content

Get the first n rows

Description

$limit() is an alias for $head().

Usage

<LazyFrame>$head(n = 5)

lazyframe__limit(n = 5)

Arguments

n Number of rows to return.

Value

A polars LazyFrame

Examples

library("polars")

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