My first dataframe looks like this, df:
lastUpdated midprice returns
2020-05-12 00:19:10 0.000200 NaN
2020-05-12 00:19:20 0.000200 0.000000
2020-05-12 00:19:30 0.000200 0.000025
...
2020-05-12 06:56:40 0.000206 -0.000049
2020-05-12 06:56:50 0.000206 0.000000
2020-05-12 06:57:00 0.000206 0.000000
My second dataframe looks like this, df2:
ts 1.38259 lastUpdated
lastUpdated
2020-05-12 00:19:10 1.589244e+12 3.36436 2020-05-12 00:42:32.202
2020-05-12 00:19:20 1.589244e+12 3.34661 2020-05-12 00:42:23.399
2020-05-12 00:19:30 1.589244e+12 3.34661 2020-05-12 00:42:23.399
2020-05-12 00:19:40 1.589244e+12 3.15296 2020-05-12 00:40:47.384
...
2020-05-12 06:59:30 1.589267e+12 35.121100 2020-05-12 06:58:24.165
2020-05-12 06:59:40 1.589267e+12 35.121100 2020-05-12 06:58:24.165
2020-05-12 06:59:50 1.589267e+12 35.521100 2020-05-12 06:57:31.452
What I need to do is to merge the dataframe like the below:
lastUpdated midprice returns 1.38259
2020-05-12 00:19:10 0.000200 NaN 3.34661
2020-05-12 00:19:20 0.000200 0.000000 3.34661
2020-05-12 00:19:30 0.000200 0.000025 3.15296
....
So the column 1.38259 is shifted by Index+1, I tried to do with merge but I am unable to do Index+1, I do not know if you understand what I try to achieve... any help? thanks!!