1

我试图找到列 ['High'] 和 ['Low'] 之间的 5 个周期的滚动相关性。

我设法计算它,但有一个错误:

FutureWarning:pd.rolling_corr 已被 Series 弃用,将在未来版本中删除,替换为 Series.rolling(window=5).corr(other=)

尝试更换它,但它不起作用。有什么帮助吗?

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())
4

1 回答 1

1

尝试使用

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

注意

pd.rolling_corr(df['Col1'],df['Col2'],window=5)#panda V 0.17 (notice pd.rolling_corr is deprecated for Series )
于 2017-09-12T03:02:09.653 回答