r/Python • u/AutoModerator • 4h ago
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
6
Upvotes
r/Python • u/AutoModerator • 4h ago
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
View all comments
•
u/import_pandas_as_np 20m ago
polars-stats:scipy.stats-style probability distributions as Polars expressions, with per-row parametersWhat My Project Does
polars-statsbringsscipy.stats-style probability distributions into Polars as native expressions: densities, cdf/sf, quantiles (ppf/isf), their log variants, moments and seeded sampling. Parameters can be columns, so one expression evaluates a different distribution on every row, inside a lazy query.sample(seed=...)gives the same draws on the in-memory and streaming engines, at any thread count.log_sf/log_cdfstay finite deep in the tails, tested against an arbitrary-precision oracle (mpmath).Target Audience
People who already keep their data in Polars and need per-row probability work: anomaly scoring against per-entity baselines, posterior intervals per A/B variant, Monte Carlo simulation inside a pipeline.
It is a young project, tested against scipy on every distribution and method; method names follow scipy.
Requests for missing distributions are welcome.
Comparison
norm(loc=mu, scale=sigma).sf(x)), and it is the reference polars-stats is tested against. The difference is where the result lands: scipy returns a NumPy array, so a lazy query has to collect, convert, and stitch the result back in, and nulls become NaN. polars-stats stays an expression, so the optimiser keeps working around it (a later filter is still pushed down).map_batcheswith scipy inside keeps the work in the plan, but as an opaque Python callback.Links: