Instead of e.g. calculating the sum with group_by I would like to concatenate all rows within the same group. Instead of sum() the code beneath should just combine/ concat the rows. If there would be 5 rows per group the new data frame would have 5-times the columns (each column x 5)
Example: This is the data frame I have right now.
Index Pool B C D E
70 Pool1 8.717402 7.873173 16.029238 8.533174
71 Pool1 7.376365 6.228181 9.272679 7.498993
72 Pool2 8.854857 10.340896 9.218947 8.670379
73 Pool2 11.509130 8.571492 19.363829 14.605199
74 Pool3 14.780578 7.405982 9.279374 13.551686
75 Pool3 7.448860 11.952275 8.239564 12.264440
I want to have it like this:
Index Pool B1 C1 D1 E1 B2 C2 D2 E2
70 Pool1 8.717402 7.873173 16.029238 8.533174 7.376365 6.228181 9.272679 7.498993
71 Pool2 8.854857 10.340896 9.218947 8.670379 11.509130 8.571492 19.363829 14.605199
72 Pool3 14.780578 7.405982 9.279374 13.551686 7.448860 11.952275 8.239564 12.264440
I would provide you with sample code but have no idea. If I would just sum the rows up I would use:
t.groupby(['pool']).sum()
But I do not want to combine the rows and keep the column structure, I want to concatenate the rows with the same group.
df['B']would essentially be an ambiguous statement. Such non-unique columns seem somewhat odd to me.