Skip to main content

Polars backend adapter for PlanFrame.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

planframe-polars

Docs PyPI License: MIT

Polars adapter package for PlanFrame. Import as planframe_polars.

Documentation (ReadTheDocs):

  • Polars track (end users): https://planframe.readthedocs.io/en/latest/planframe_polars/
  • Light API reference: https://planframe.readthedocs.io/en/latest/planframe_polars/reference/api/

Usage

import polars as pl

from planframe_polars import PolarsFrame


class User(PolarsFrame):
    id: int
    age: int

pf = User(pl.DataFrame({"id": [1], "age": [2]}))
df = pf.select("id").collect()

# Common transforms
#
# PlanFrame is always lazy; these build a plan until `collect()`.
pf3 = pf.with_row_count(name="row_nr").clip(lower=0, subset=("age",))
pf4 = pf.rename_upper().cast_many({"age": float})

# Or construct from python data:
pf2 = User({"id": [1], "age": [2]})

Execution model

PlanFrame is always lazy:

  • Chaining methods (like .select(...)) does not run Polars operations.
  • collect() evaluates the full plan. If the source is a polars.LazyFrame, this naturally compiles into a single lazy query before collecting.

Notes (Polars-specific)

  • Pivot: LazyFrame.pivot(...) requires on_columns to be provided up-front (Polars must know the output schema prior to collect()). PlanFrame enforces this at execution time.
  • pivot_wider: wrapper around pivot(...); for deterministic output columns on lazy sources, pass on_columns.
  • concat_vertical: implemented via polars.concat(..., how="vertical").
  • Join: implemented via LazyFrame.join(...) / DataFrame.join(...) with symmetric on or asymmetric left_on / right_on, plus optional JoinOptions mapped to Polars (nulls_equal, validate, coalesce, maintain_order, allow_parallel / force_parallel, streaming, engine_streaming when supported by the installed Polars).
  • Group by / agg: group_by compiles to Polars group_by with column or expression keys (expression keys are aliased __pf_g{i}). agg compiles tuple reductions to pl.col(...).sum()-style calls and AggExpr to aggregated expressions on compiled inners (e.g. agg_sum(truediv(col("a"), col("b")))).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

planframe_polars-0.7.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

planframe_polars-0.7.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file planframe_polars-0.7.0.tar.gz.

File metadata

  • Download URL: planframe_polars-0.7.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for planframe_polars-0.7.0.tar.gz
Algorithm Hash digest
SHA256 224e794ef317895baae099d8e6c35984ddab4653bb843e55e04c1c0ba78af611
MD5 c8974f1efc5571b472fdc428ac3bd18c
BLAKE2b-256 269b0a308e6006dd4320f141f11f52f22f4a2b44fad877893e8b6ffe75507984

See more details on using hashes here.

File details

Details for the file planframe_polars-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for planframe_polars-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92964d0af554a442cf33388286b63171589cbb287785b20241d8a21920edd7ef
MD5 e3f592c9ddd743974af0e6dcc069f7b9
BLAKE2b-256 c9ae9236821db448c0c1621b980e7b90194eba2066e51deccfac57570f598c0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page