Skip to content

LazyFrame Reference

polynx.LazyFrame wraps polars.LazyFrame with the complete suite of Polynx string expression methods and enhanced lazy indexing.

import polynx as plx

lazy_df = plx.DataFrame(data).lazy()

Standard Polars LazyFrame Methods

polynx.LazyFrame inherits all native Polars lazy operations and optimization passes.

This page covers only the Polynx-specific lazy extensions. For standard Polars LazyFrame methods, please refer to the Official Polars LazyFrame Reference.


Lazy Execution Model

All operations on a LazyFrame are deferred into a query plan and executed only when .collect() is called:

result = (
    lazy_df
    .wc("A_doubled = A * 2")
    .query("A_doubled > 10")
    .collect()
)

Methods Inherited from DataFrame

The following methods are implemented for LazyFrame and operate lazily:


Lazy Indexing Syntax

Polynx enhances LazyFrame with bracket indexing:

Column Selection

# Select single column
lazy_df['column_name']

# Select multiple columns
lazy_df[['col_a', 'col_b']]

Expression Filtering

import polars as pl

# Filter rows lazily via indexing
lazy_df[pl.col('A') > 5]

Interoperability & Conversions

collect

Execute the query plan and materialize a polynx.DataFrame.

lazy_df.collect() -> polynx.DataFrame

to_polars

Retrieve the underlying native polars.LazyFrame.

lazy_df.to_polars() -> polars.LazyFrame

to_pandas

Collects the lazy frame and converts the result into a pandas.DataFrame.

lazy_df.to_pandas() -> pandas.DataFrame