Python 中的时间序列分析
Rob Reider
Adjunct Professor, NYU-Courant Consultant, Quantopian


相关系数 = 0.9

相关系数 = -0.9

相关系数 = 0.4

相关系数 = 1.0

道琼斯工业平均指数与UFO目击(www.nuforc.org)

水平(价格)相关系数:0.94
df['SPX_Ret'] = df['SPX_Prices'].pct_change()
df['R2000_Ret'] = df['R2000_Prices'].pct_change()
plt.scatter(df['SPX_Ret'], df['R2000_Ret'])
plt.show()

correlation = df['SPX_Ret'].corr(df['R2000_Ret'])
print("Correlation is: ", correlation)
Correlation is: 0.868
Python 中的时间序列分析