Materialize this LazyFrame into a DataFrame
Description
By default, all query optimizations are enabled. Individual
optimizations may be disabled by setting the corresponding parameter to
FALSE.
Usage
<LazyFrame>$collect(
...,
engine = c("auto", "in-memory", "streaming"),
optimizations = pl\$QueryOptFlags()
)
Arguments
Value
A polars DataFrame
See Also
-
$sink_parquet()streams query to a parquet file. -
$sink_ipc()streams query to a arrow file.
Examples
library("polars")
lf <- pl$LazyFrame(
a = c("a", "b", "a", "b", "b", "c"),
b = 1:6,
c = 6:1,
)
lf$group_by("a")$agg(pl$all()$sum())$collect()
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ str ┆ i32 ┆ i32 │
#> ╞═════╪═════╪═════╡
#> │ a ┆ 4 ┆ 10 │
#> │ b ┆ 11 ┆ 10 │
#> │ c ┆ 6 ┆ 1 │
#> └─────┴─────┴─────┘
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ str ┆ i32 ┆ i32 │
#> ╞═════╪═════╪═════╡
#> │ a ┆ 4 ┆ 10 │
#> │ b ┆ 11 ┆ 10 │
#> │ c ┆ 6 ┆ 1 │
#> └─────┴─────┴─────┘