Error Msg: replace with Series.rolling(window=5).corr(other=<Series>)

Question:

I am trying to find the rolling correlation of 5 periods between columns [‘High’] and [‘Low’].

I manage to calculate it but there is an error:

FutureWarning: pd.rolling_corr is deprecated for Series and will be removed in a future version, replace with
Series.rolling(window=5).corr(other=)

Tried replacing it but it doesnt work. Any help?

import pandas as pd
df_Gold = pd.read_csv('GoldData.csv')
df_Gold['High_Low'] = pd.rolling_corr(df_Gold['High'],df_Gold['Low'],5)
print(df_Gold.tail())
Asked By: NewCoder

||

Answers:

Try using

df['Col1'].rolling(5).corr(df['Col2'])#pandas V 0.20

Notice

pd.rolling_corr(df['Col1'],df['Col2'],window=5)#panda V 0.17 (notice pd.rolling_corr is deprecated for Series )
Answered By: BENY