This project has been archived by its maintainers, and is no longer receiving any updates.
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/
Install
pip install planframe-polars
Usage
from planframe_polars import PolarsFrame
class User(PolarsFrame):
id: int
age: int
# Construct from python data:
pf = User({"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_index(name="row_nr").clip(lower=0, subset=("age",))
pf4 = pf.rename_upper().cast_many({"age": float})
# If you already have a Polars DataFrame/LazyFrame, use `Frame.source(...)`:
import polars as pl
pf2 = User.source(pl.DataFrame({"id": [1], "age": [2]}).lazy(), adapter=User._adapter_singleton, schema=User)
Execution model
Core v1.2.0+ (current minor v1.3.x) includes execute_plan_async, planframe.materialize, discoverable Frame async aliases (collect_async, to_dict_async, …), and v1.3.0 adapter/typing additions—see the migration guide and API reference.
PlanFrame is always lazy:
- Chaining methods (like
.select(...)) does not run Polars operations. collect()evaluates the full plan (and returnslist[pydantic.BaseModel]).- If you need a backend-native
polars.DataFrame/polars.LazyFrame, usecollect_backend(). - If you want to iterate rows, use
stream_dicts()/stream()(see the Streaming rows guide).
Optional API skins (core)
The core package includes typed mixins you can combine with PolarsFrame if you want a different surface API (same lazy plan underneath):
planframe.spark.SparkFrame: PySpark-like column access,withColumns,groupBy().agg(...),hint(), … — see PySpark-like API.planframe.pandas.PandasLikeFrame: pandas-like naming — see pandas-like API (the pandas adapter’sPandasFrameuses this mixin by default).
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. - vstack: 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/force_parallel,streaming,engine_streamingwhen supported by the installed Polars). - 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")))).
Metadata
Release files for planframe-polars 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| planframe_polars-1.3.0.tar.gz | 13.0 kB | Without provenance | Details for planframe_polars-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| planframe_polars-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for planframe_polars-1.3.0-py3-none-any.whl |
Total release size: 27.9 kB
Release files / planframe_polars-1.3.0.tar.gz
| Download URL | planframe_polars-1.3.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
072e13651195472889b57b95fba7077fb9aea3ae3d4fbb4fc528e4fed3415ca8
|
|
BLAKE2b-256 checksum How to use checksums |
757eb3e71f1bf6bc56da12cc637a92bfc390f1918b75a5ee6448a1eedb0a491e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / planframe_polars-1.3.0-py3-none-any.whl
| Download URL | planframe_polars-1.3.0-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10c408ee95e042e4b87e4056229addc49a483081f42ec18e45aa05296bb503ef
|
|
BLAKE2b-256 checksum How to use checksums |
99189425e0113c1afa197ba18fbca0543cfdff54b9f6f5a9f838c23675674a1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for planframe-polars 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.