4

I am using pandas with version 0.23.4 and the below code is giving me the error - "module 'pandas' has no attribute 'rolling_apply'"

Below is the function call:

df['perLow'] = pd.rolling_apply(df.low, 2, add_percentage_diff)

Any help with fixing this error is much appreciated.

cs95
  • 379,657
  • 97
  • 704
  • 746
Nikicatz
  • 105
  • 2
  • 11

1 Answers1

10

The pd.rolling_* family of functions were replaced by Rolling objects associated with DataFrames around v0.18.

Use Rolling.apply:

df['low'].rolling(2).apply(add_percentage_diff)
cs95
  • 379,657
  • 97
  • 704
  • 746