【发布时间】:2019-06-14 08:45:35
【问题描述】:
我有一个包含时间序列的数据框(单只股票的每日价格)。我想采用两个不同的时间范围并将它们覆盖在相对起点为 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)
【问题讨论】:
标签: python python-3.x matplotlib time-series