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(
...,
type_coercion = TRUE,
`_type_check` = TRUE,
predicate_pushdown = TRUE,
projection_pushdown = TRUE,
simplify_expression = TRUE,
slice_pushdown = TRUE,
comm_subplan_elim = TRUE,
comm_subexpr_elim = TRUE,
cluster_with_columns = TRUE,
no_optimization = FALSE,
engine = c("auto", "in-memory", "streaming"),
`_check_order` = TRUE,
`_eager` = FALSE,
collapse_joins = deprecated()
)
Arguments
Value
A polars DataFrame
See Also
-
$profile()
- same as$collect()
but also returns a table with each operation profiled. -
$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 │
#> ╞═════╪═════╪═════╡
#> │ b ┆ 11 ┆ 10 │
#> │ c ┆ 6 ┆ 1 │
#> │ a ┆ 4 ┆ 10 │
#> └─────┴─────┴─────┘
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ str ┆ i32 ┆ i32 │
#> ╞═════╪═════╪═════╡
#> │ b ┆ 11 ┆ 10 │
#> │ c ┆ 6 ┆ 1 │
#> │ a ┆ 4 ┆ 10 │
#> └─────┴─────┴─────┘