Skip to content

Dataframe backends

The shared dataframe package includes a Polars backend and supports eager and lazy dataframes. The built-in Engine uses this backend for dataframe operations.

Dataframe backends shared by runtime components.

DataFrameBackend

Bases: Protocol

Operations supported by a dataframe backend.

name instance-attribute

name: str

is_frame

is_frame(value: object) -> bool

to_frame

to_frame(value: object) -> object

column_names

column_names(frame: object) -> list[str]

select

select(frame: object, columns: Sequence[str]) -> object

snapshot

snapshot(frame: object) -> object

collect_pair

collect_pair(left: object, right: object) -> tuple[object, object]

is_duplicated

is_duplicated(frame: object) -> bool

row_count

row_count(frame: object) -> int

same_keys

same_keys(left: object, right: object, keys: Sequence[str]) -> bool

same_data

same_data(left: object, right: object, columns: Sequence[str], *, sort_by: Sequence[str] = ()) -> bool

validate_types

validate_types(frame: object, types: Mapping[str, str]) -> None

PolarsBackend

Polars implementation of the dataframe backend contract.

name class-attribute instance-attribute

name = 'polars'

is_frame

is_frame(value: object) -> bool

to_frame

to_frame(value: object) -> frame_types.PolarsFrame

column_names

column_names(frame: object) -> list[str]

select

select(frame: object, columns: Sequence[str]) -> object

snapshot

snapshot(frame: object) -> object

Copy an input without changing its dataframe interface.

collect_pair

collect_pair(left: object, right: object) -> tuple[object, object]

Collect related lazy frames together so they can share upstream work.

is_duplicated

is_duplicated(frame: object) -> bool

row_count

row_count(frame: object) -> int

Return the row count without materializing all columns of a lazy frame.

same_keys

same_keys(left: object, right: object, keys: Sequence[str]) -> bool

Compare observation identities without assuming physical row order.

same_data

same_data(left: object, right: object, columns: Sequence[str], *, sort_by: Sequence[str] = ()) -> bool

Compare selected rows and values, optionally in key order.

validate_types

validate_types(frame: object, types: Mapping[str, str]) -> None

Check declared logical column types against the returned schema.