df['g'] = (df.groupby('id').cumcount() + 1).astype(str)
df1 = df.set_index(['id', 'g']).unstack()
df1.sort_index(axis=1, level=1, inplace=True)
Combine multiple time-series rows into one row with Pandas