polars.DataFrame.lazy#

DataFrame.lazy() LazyFrame[source]#

Start a lazy query from this point. This returns a LazyFrame object.

Operations on a LazyFrame are not executed until this is requested by either calling:

  • .fetch()

    (run on a small number of rows)

  • .collect()

    (run on all data)

  • .describe_plan()

    (print unoptimized query plan)

  • .describe_optimized_plan()

    (print optimized query plan)

  • .show_graph()

    (show (un)optimized query plan as graphviz graph)

Lazy operations are advised because they allow for query optimization and more parallelization.

Returns:
LazyFrame

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [None, 2, 3, 4],
...         "b": [0.5, None, 2.5, 13],
...         "c": [True, True, False, None],
...     }
... )
>>> df.lazy()  
<LazyFrame [3 cols, {"a": Int64 … "c": Boolean}] at ...>