Polars 2 · Lazy queries and files

Write and run a lazy query

Chain operations on a LazyFrame, then collect the result.

result = (
    pl.scan_csv("big.csv")
    .filter(pl.col("amount") > 100)
    .group_by("region")
    .agg(pl.col("amount").sum())
    .collect()
)

Official Polars 2 documentation

More lazy queries and files commands

All lazy queries and files commands · Polars 2 cheatsheet

Was this page helpful?