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
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 apolars.LazyFrame, this naturally compiles into a single lazy query before collecting.
Notes (Polars-specific)
- Pivot:
LazyFrame.pivot(...)requireson_columnsto be provided up-front (Polars must know the output schema prior tocollect()). PlanFrame enforces this at execution time. - pivot_wider: wrapper around
pivot(...); for deterministic output columns on lazy sources, passon_columns. - concat_vertical: implemented via
polars.concat(..., how="vertical"). - Join: implemented via
LazyFrame.join(...)/DataFrame.join(...)with symmetriconor asymmetricleft_on/right_on, plus optionalJoinOptionsmapped to Polars (nulls_equal,validate,coalesce,maintain_order,allow_parallel/ streaming). - Group by / agg:
group_bycompiles to Polarsgroup_bywith column or expression keys (expression keys are aliased__pf_g{i}).aggcompiles tuple reductions topl.col(...).sum()-style calls andAggExprto aggregated expressions on compiled inners (e.g.agg_sum(truediv(col("a"), col("b")))).
Project details
Release history Release notifications | RSS feed
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.6.0.tar.gz
(11.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file planframe_polars-0.6.0.tar.gz.
File metadata
- Download URL: planframe_polars-0.6.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b890757c9cee98d88108f8fffe08213bf897b9a8c459a4219f725a7c53aa96ac
|
|
| MD5 |
9b7b3587aa1d32cda088f5e0f91e8a3a
|
|
| BLAKE2b-256 |
db1ffef577508aee90d75cbff1843d1cc9a4d6af752f8fc4a87c815311a29f24
|
File details
Details for the file planframe_polars-0.6.0-py3-none-any.whl.
File metadata
- Download URL: planframe_polars-0.6.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65f03d5a2b47279eb0cf5941059c84c475094ac3915f9a6a030eb159e043f6a
|
|
| MD5 |
e213a84d1684bd3bffdb04835ac7072e
|
|
| BLAKE2b-256 |
1c62bbce21287490baa95f66211be035412da96f77dbbc27e874bdccdec91d43
|