I have a dataframe in pandas which contains multiple columns. I want to merge every row with the next row. Example:
input dataframe:
A B C
a1 a2 a3
b1 b2 b3
c1 c1 c3
d1 d2 d3
output dataframe:
A1 B1 C1 A2 B2 C2
a1 a2 a3 b1 b2 b3
b1 b2 b3 c1 c2 c3
c1 c2 c3 d1 d2 d3
d1 d2 d3 NaN NaN NaN
The solusion I came up with was copying the original dataframe, changing the index to be index - 1, and then merging the two data frames by index. Is there any other solution?