Metadata-Version: 2.4
Name: polars-distr
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Requires-Dist: polars>=1.42.1,<1.44
Requires-Dist: numpy>=1.26 ; extra == 'reference'
Requires-Dist: mpmath>=1.3 ; extra == 'tests'
Requires-Dist: numpy>=1.26 ; extra == 'tests'
Requires-Dist: pytest ; extra == 'tests'
Provides-Extra: reference
Provides-Extra: tests
License-File: LICENSE
Summary: Native Polars expressions for histogram distribution statistics
Keywords: polars,histogram,probability,statistics,crps
Author-email: Silurian AI <contact@silurian.ai>
License-Expression: Apache-2.0
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Issues, https://github.com/silurian-ai/polars-distr/issues
Project-URL: Repository, https://github.com/silurian-ai/polars-distr

# polars-distr

Native Polars expressions for statistics over histogram distributions. The plugin
computes means, CDF values, quantiles, and exact CRPS inside lazy and streaming query
plans without Python UDFs. `histogram()` gives the unchanged `Struct{counts, edges}`
storage a logical histogram dtype that survives lazy plans and Parquet round trips.

Install with `uv add polars-distr` or `pip install polars-distr`.

```python
import polars as pl
import polars_distr as pld  # registers the Histogram dtype

result = (
    pl.scan_parquet("histograms.parquet")
    .select(
        pld.quantiles("distribution", [0.1, 0.5, 0.9]).alias("quantiles"),
        pld.crps("distribution", "observation").alias("crps"),
    )
    .collect(engine="streaming")
)
```

Create `distribution` from raw columns with
`pld.histogram("counts", "edges")`; once written to Parquet, it loads back as a
histogram column.

- [Semantics](https://github.com/silurian-ai/polars-distr/blob/main/docs/semantics.md)
- [Architecture](https://github.com/silurian-ai/polars-distr/blob/main/docs/architecture.md)
- [Benchmarks](https://github.com/silurian-ai/polars-distr/blob/main/docs/benchmarks.md)

