Core typed relational planning layer for Python DataFrames.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
planframe
Core package for PlanFrame (typed planning layer). Import as planframe.
Documentation (ReadTheDocs):
- Core (adapter authors):
https://planframe.readthedocs.io/en/latest/planframe/ - Design docs:
https://planframe.readthedocs.io/en/latest/planframe/design/ - Light API reference:
https://planframe.readthedocs.io/en/latest/planframe/reference/api/
What you get
planframe.Frame: immutable, schema-aware transformation plan (always lazy)planframe.expr: typed expression IR (col,lit, arithmetic/compare/boolean ops,coalesce,if_else, etc.), plus aggregation wrappers for use insidegroup_by(...).agg(...):agg_sum,agg_mean,agg_min,agg_max,agg_count,agg_n_unique(these buildAggExprnodes)planframe.groupby.GroupedFrame: produced byFrame.group_by;group_byaccepts column names and/or expressions (expression keys show up as__pf_g0,__pf_g1, … in the result schema).aggaccepts(op, column)tuples and/orAggExprvalues—not arbitrary bare expressionsplanframe.schema: schema reflection (dataclass + Pydantic) and materialization
Common transforms
Some commonly used Frame transforms:
with_row_count(name="row_nr", offset=0): add a monotonically increasing row number column.clip(lower=..., upper=..., subset=...): clamp numeric columns (ifsubset=None, clamps all numeric schema fields).select_schema(selector, strict=True): schema-only selectors (backend-independent).cast_many(mapping, strict=True)/cast_subset(*columns, dtype, strict=True): multi-column cast helpers.fill_null_subset(value|strategy, *columns)/fill_null_many(mapping, strict=True): multi-column fill-null helpers.rename_upper/lower/title/strip(...): schema-driven rename helpers.pivot_longer(...)/pivot_wider(...): reshape convenience wrappers aroundmelt/pivot.
Note on backends
planframe is backend-agnostic. It does not execute anything until collect() (even for eager backends). To execute plans you need an adapter package (e.g. planframe-polars).
For async stacks, Frame.acollect(), Frame.ato_dicts(), and Frame.ato_dict() await adapter hooks (BaseAdapter.acollect and friends); defaults run sync methods in a thread pool. See https://planframe.readthedocs.io/en/latest/planframe/design/backend-adapter-design/.
Typing
PlanFrame includes py.typed plus generated stubs (notably planframe/frame.pyi) to improve static typing in editors and Pyright.
If you modify the Frame API, regenerate stubs from the repo root:
python scripts/generate_typing_stubs.py
python scripts/generate_typing_stubs.py --check
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
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-0.5.0.tar.gz.
File metadata
- Download URL: planframe-0.5.0.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e0c07bb291fce6e2e0737f2bb425d1e706f82fef100516af9ae4c9146dca2a2
|
|
| MD5 |
6934677ed9f6952821d271a605120bfa
|
|
| BLAKE2b-256 |
cb92520376dde4ffe221530e3d13d8c945f253f841f1d06cb1980ed12838741c
|
File details
Details for the file planframe-0.5.0-py3-none-any.whl.
File metadata
- Download URL: planframe-0.5.0-py3-none-any.whl
- Upload date:
- Size: 42.9 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 |
b7c2bb9eb16dc7582ba3709316d8478b857424c2d755aecfa659100859128839
|
|
| MD5 |
aa88acf7e6a9d86284f168a45c91471c
|
|
| BLAKE2b-256 |
b292b50fcf7c7d69c40ceff52340ffd362fce0f2baafb5d37c292c4208d1e16f
|