我有一个包含选项数据的DataFrame。对于每个元素,我有一个当前日期和到期日期。我有一个两级Multi索引,如下所示:
symbol exchange adjusted stock close price \
date expiration
01/31/90 02/17/90 SPX CBOE 329.08
02/17/90 SPX CBOE 329.08
02/17/90 SPX CBOE 329.08
02/17/90 SPX CBOE 329.08
02/17/90 SPX CBOE 329.08
......
......
......
symbol exchange adjusted stock close price \
date expiration
02/14/14 12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
还有其他专栏,但例如,他们无关紧要。我想要做的,我可能只是不清楚转移的文件,是通过第一级索引向下或向上移动所有数据。因此,将所有数据从下一个日期索引转移到上一个日期索引。因此,如果示例之间没有其他日期,我想要一个看起来像这样的DataFrame:
symbol exchange adjusted stock close price \
date expiration
01/31/90 12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
12/16/16 SPX CBOE 1838.63
......
.......
.......
symbol exchange adjusted stock close price \
date expiration
02/14/14 THIS WOULD HAVE NaN data because it's the last set
这有什么意义吗?我们的想法是将所有数据上移一段时间来计算价格变化。