我有一个带有时间序列的数据框(单只股票的每日价格)。我想取两个不同的时间范围,并将它们覆盖在相对起点为0而不是日期的绘图上
在下面的示例中,如果我绘制1962年和2018年,它使用日期作为x轴,而不是相对起点
SPY = pd.read_csv('GSPC.csv', parse_dates=['dDate'], index_col='dDate')
SPY1962 = SPY['1962']
SPY2018 = SPY['2018']
firstprice62 = SPY1962['nAdjClose'].iloc[0]
firstprice18 = SPY2018['nAdjClose'].iloc[0]
normal62 = SPY1962['nAdjClose'].div(firstprice62).mul(100)
normal18 = SPY2018['nAdjClose'].div(firstprice18).mul(100)
我明白了
相关问题 更多 >
编程相关推荐