I was wondering if there is a way to groupby consecutive index numbers and move the groups in different columns. Here is an example of the DataFrame I\'m using:
One way from pandas groupby
pandas
groupby
s=df.index.to_series().diff().ne(1).cumsum() pd.concat({x: y.reset_index(drop=True) for x, y in df['0'].groupby(s)}, axis=1) Out[786]: 1 2 0 19218.965703 19279.216956 1 19247.621650 19330.087371 2 19232.651322 19304.316973