Skip to main content

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")
)

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, and edges; the v0.1 histogram and counts names are removed.
  • The extension identity is polars_distr.piecewise_uniform.v1. Data written with the pre-contract polars_distr.distribution.v1 identity 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

polars_distr-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

polars_distr-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl (6.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

polars_distr-0.2.0-cp311-abi3-macosx_11_0_arm64.whl (5.9 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file polars_distr-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polars_distr-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9f084bcdf4b8b2eba55a04492591e5fb9b63f9a7f24369e32853ad4654d9e658
MD5 38c151776e5301cdb2d4e463d6cbb8eb
BLAKE2b-256 f8212e90f1fff5a99f7436be6d4f1428a125f3f52fbf28da7605c9a6a1e8a8e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_distr-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on silurian-ai/polars-distr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_distr-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for polars_distr-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2563074669778e654fd4ce7efa58bedeedc2240187f97c244b4cbe249a079401
MD5 d7f4680713d610c2e6d88891e41a0549
BLAKE2b-256 3f6cdf1172614bd14949f8b7fa793377204e9f3e1731f8877843db5d85b899bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_distr-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on silurian-ai/polars-distr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_distr-0.2.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_distr-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30be86b2d24c58fbd7b4645c525d23e9d5b5a4da190632cd7b3f557c36384b04
MD5 c3b8b37e9b561080a11b7e10e4f3972d
BLAKE2b-256 7d5f1c449a0c32a92399351519b1e7725d68bc784a2ab49304ff05d4e03b8b95

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_distr-0.2.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on silurian-ai/polars-distr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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