Pandas: joining items with same index,"df.assign(id=df.groupby([0]).cumcount()).set_index(['id', 0]).unstack(level=1)"