Pandas. Group by field and merge the values in a single row,df.set_index('id').stack().unstack()