I have a table like this name df1
ID M1 M2 NO DTime Result(P2-P3) (P1-P2) (P1-P7) (P3-P7)
2801596 288 371 536529 08-02-2023 11:07 1 NaN 0.085 NaN NaN
2801596 289 371 536529 08-02-2023 11:07 1 1 0.032 1.081 NaN
2801584 290 372 541278 08-02-2023 11:10 1 NaN 0.081 NaN NaN
2801584 291 372 541278 08-02-2023 11:10 0 1 0.037 1.065 NaN
2801598 288 371 541279 08-02-2023 11:12 1 NaN 0.076 NaN NaN
2801599 288 371 555623 08-02-2023 11:14 1 1 NaN NaN 3.871
2801599 289 371 555623 08-02-2023 11:14 1 1 NaN NaN 2.389
2801600 291 372 555624 08-02-2023 11:18 1 NaN 0.0835 NaN NaN
I have tried using Pivot table but it is giving a table full of Nan.
df2 = pd.pivot_table(df1, values=['Result','(P2-P3)','(P1-P2)','(P1-P7)','(P3-P7)'], index=['ID','No','DTime'],columns=['M2','M1'], aggfunc='first')
