I am looking for rolling_product similar to rolling_sum in polars. Rolling_apply sum is slow compared to rolling_sum.
If it’s not possible, need help to create rolling_prod function. Unable to locate rolling_sum in GIT. Could someone share the location of rolling_sum in git
There is currently no
rolling_productin Polars. You can construct yourself usingrolling_applyas you say, but this is not the most efficient as it recomputes the product over each window every time as you have found out.I can think of two possible solutions that may be faster by avoiding complete recomputation and can readily be implemented using existing methods. Note, haven't benchmarked either of these, and for sure a specialized implementation will beat these approaches.
a * bcan be written asexp(log(a) + log(b)). So you could do something likeThis may introduce numeric instabilities though, and wont work with non-positive numbers.