on-internet
← Community

How to Write Poisson CDF as Python Polars Expression

Stack Overflow ·

I have a collection of polars expressions being used to generate features for an ML model. I'd like to add a poission cdf feature to this collection whilst maintaining lazy execution (with benefits of speed, caching etc...). I so far have not found an easy way of achieving this. I've been able to get the result I'd like outside of the desired lazy expression framework with: import polars as pl from scipy.stats import poisson df = pl.DataFrame({"count": [9,2,3,4,5], "expected_count": [7.7, 0.2, 0.7, 1.1, 7.5]}) result = poisson.cdf(df["count"].to_numpy(), df["expected_count"].to_numpy()) df = d

Comments

Sign in or sign up to comment and upvote.

No comments yet.