-1

All, I found a solution for rolling cumulative product in Python here - prior solution

But when I try to implement this functionality, I get the following output -

AttributeError: module 'pandas' has no attribute 'rolling_apply'

I think pandas removed this functionality in more recent versions, does anyone have a more current solution for a rolling cumprod() for columns in a dataframe?

Thanks!

EDIT

All, thank you for your messages. I tried this - link - and got the same AttributeError: module 'pandas' has no attribute 'rolling_apply' issue as before. An example of the dataframe and expected output is in the image below. This would be the rolling cumprod of the last 2 rows of data in raw_data.

enter image description here

  • show an example of you r dataframe an your expected output. See DataFrame.rolling – ansev Nov 02 '19 at 16:52
  • 1
    Second Answer in this thread. https://stackoverflow.com/questions/15295434/how-to-calculate-rolling-cumulative-product-on-pandas-dataframe – Michael Gardner Nov 02 '19 at 16:53

1 Answers1

0

All, figured it out, rolling_apply was deprecated. This functionality worked -

df['output'] = df['input'].rolling(5).apply(lambda x: x.prod())

Thanks for your help!