Skip to content

Tag: rolling-computation

Getting Rolling Sum per Group

I have a dataframe like this: I would like to get the Sum of the last three months (excluding the current month), per Product_ID. Therefore I tried this: My code is failing, because it does not only calculate it per product, but it will give me also numbers for other products (let’s say Product 2, quart…

non fixed rolling window

I am looking to implement a rolling window on a list, but instead of a fixed length of window, I would like to provide a rolling window list: Something like this: and the result would be: 6.67 is calculated as average of 3 elements 10, 2, 8. I implemented a slow solution, and every idea is welcome to make it