I have used in the past a groupby operation as mentioned here to group a dataframe by every n
rows. But, how can I preform an operation a dataframe that has a datetime index? When I try it on the following dataframe,
a b c
time
2020-04-17 10:42:32.214624 538.401442 7260.312500 -713.166667
2020-04-17 10:42:33.086562 555.252404 7352.187500 -713.373264
2020-04-17 10:42:44.107187 572.103365 7444.062500 -713.579861
2020-04-17 10:42:44.648343 588.954327 7535.937500 -713.786458
2020-04-17 10:42:51.070750 605.805288 7627.812500 -713.993056
2020-04-17 10:42:53.567468 622.656250 7719.687500 -714.199653
I get the following error:
TypeError: cannot perform __truediv__ with this index type: DatetimeIndex
Is there a way that I can do a groupby, or some other operation to get groups of every 2 rows while keeping the datetime index?