0

I have a dataframe, I need to flatten it with respect to ID(A guid in my case). I am dealing with sensor data here, the number of columns are very high. Using the following answer from following post for doing the operation for each id in a separate dataframe. Flatten the dataframe in pandas

Is it possible to get the following results. `

df = pd.DataFrame({ 'id': ["AA", "AA", "BB", "BB"], 'A': [10, 20, 30, 40], 'B': [50, 60, 70, 80], 'C': [90, 100, 110, 120] })

print(df)

    id   A   B    C
0   AA  10  50   90
1   AA  20  60  100
2   BB  30  70  110
3   BB  40  80  120

#I want something like the following.

print(result_df)

id  A1   B1   C1   A2   B2   C2
0  AA  10   50   90   20   60  100
1  BB  30   70  110   40   80  120
snl_lns
  • 3
  • 3

0 Answers0