Native Polars expressions for piecewise-uniform distribution statistics
Project description
polars-distr
Native Polars expressions for statistics over piecewise-uniform distributions. The plugin computes means, CDF values, quantiles, and exact CRPS inside lazy and streaming query plans without Python UDFs.
Install with uv add polars-distr or pip install polars-distr.
import polars as pl
import polars_distr as pld # registers the Distribution dtype
result = (
pl.scan_parquet("distributions.parquet")
.select(
pld.quantiles("distribution", [0.1, 0.5, 0.9]).alias("quantiles"),
pld.crps("distribution", "observation").alias("crps"),
)
.collect(engine="streaming")
)
Named quantiles
Pass quantiles() a sequence of levels for a fixed-size Array in request order, or
a name-to-level mapping for a Struct in mapping order — the same single traversal
either way:
result = frame.select(
pld.quantiles("distribution", {"p10": 0.1, "p50": 0.5, "p90": 0.9}).alias("q")
).unnest("q") # -> p10, p50, p90 columns
Values and ordering are identical target for target. Validity differs in shape only:
where the sequence form nulls the outer Array row, the mapping form yields a
non-null Struct whose every field is null, so the unnested columns keep the row and
carry the null per target.
Constructing distributions
distribution() accepts either paired fixed-width Array columns or paired
variable-width List columns:
distribution = pld.distribution("weights", "edges")
It produces the logical Distribution dtype with serialized identity
polars_distr.piecewise_uniform.v1. Its storage is a Struct with exactly
weights and edges, in that order. Fixed storage must be Array/Array with edge
width equal to weight width plus one. Ragged storage must be List/List. Mixed layouts
are rejected by the constructor and statistics kernels.
Integer, Float32, and Float64 child values are supported. Invalid distribution rows produce null results; statically invalid schemas raise during schema resolution. Raw paired Struct storage is also accepted by every statistics kernel for interoperability.
v0.2 breaking changes
- The public vocabulary is
distribution,weights, andedges; the v0.1histogramandcountsnames are removed. - The extension identity is
polars_distr.piecewise_uniform.v1. Data written with the pre-contractpolars_distr.distribution.v1identity is not guaranteed to load. distribution()accepts paired Array/Array and paired List/List storage. Mixed Array/List storage is rejected.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 polars_distr-0.2.1-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: polars_distr-0.2.1-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.0 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f1495ba2c983c964ee8065c32aaea0c8b5704ed3216c01807f775935a8e4e9d
|
|
| MD5 |
0f6c1e40931c74f16882d338660d4c3e
|
|
| BLAKE2b-256 |
02d9586fdf90a927608953adffddff0d885c834867186a3ed5c9decf8432c937
|
Provenance
The following attestation bundles were made for polars_distr-0.2.1-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on silurian-ai/polars-distr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_distr-0.2.1-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
1f1495ba2c983c964ee8065c32aaea0c8b5704ed3216c01807f775935a8e4e9d - Sigstore transparency entry: 2275789715
- Sigstore integration time:
-
Permalink:
silurian-ai/polars-distr@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/silurian-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Trigger Event:
push
-
Statement type:
File details
Details for the file polars_distr-0.2.1-cp311-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: polars_distr-0.2.1-cp311-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 6.4 MB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac429e0dc2fc1338246f479744acf4fa213c97e0fabeeab662f6d89016af8687
|
|
| MD5 |
a6e4900ed1865ff3790d0dfd25ebcd07
|
|
| BLAKE2b-256 |
d27ef813fbefdfa11f722520892cf5f4e91f490fac2bb9f2f51b5c5e12bbf34d
|
Provenance
The following attestation bundles were made for polars_distr-0.2.1-cp311-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on silurian-ai/polars-distr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_distr-0.2.1-cp311-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
ac429e0dc2fc1338246f479744acf4fa213c97e0fabeeab662f6d89016af8687 - Sigstore transparency entry: 2275789538
- Sigstore integration time:
-
Permalink:
silurian-ai/polars-distr@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/silurian-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Trigger Event:
push
-
Statement type:
File details
Details for the file polars_distr-0.2.1-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: polars_distr-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1281a3fd23618a8e14bb1876714749275885e421248c9827d7d92b536ed912d
|
|
| MD5 |
7677ef52f33fa230b387be2a56eefc5a
|
|
| BLAKE2b-256 |
22df9ae7bc5104ac32fb5938c27f22a053f272c25e3e7f777871b9c7cf488a0d
|
Provenance
The following attestation bundles were made for polars_distr-0.2.1-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on silurian-ai/polars-distr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_distr-0.2.1-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
f1281a3fd23618a8e14bb1876714749275885e421248c9827d7d92b536ed912d - Sigstore transparency entry: 2275789625
- Sigstore integration time:
-
Permalink:
silurian-ai/polars-distr@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/silurian-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e340eede2bb2a8235676a02cf470ae493f4fc9d -
Trigger Event:
push
-
Statement type: