0

i have to convert below input pandas dataframe to output dataframe ( having one row per id):

input dataframe:

id attribute score date
1 attr1 20 13-jul-21
1 attr2 30 23-jun-21
2 attr2 12 24-may-21
2 attr3 0 23-oct-21

output dataframe:

id attr1.score attr1.date attr2.score attr2.date attr3.score attr3.date
1 20 13-jul-21 30 23-jun-21 null null
2 null null 12 24-may-21 0 23-oct-21

P.S. there can be 1000's of attributes and millions of id's. i just created example with 3 attributes and 2 id's to explain the problem statement.

any suggestion would be highly appreciated, thanks :)

setianea
  • 21
  • 2
  • yes this is something i was looking for . thanks a lot. however i tried it, since i have 2 values- it is producing multiindex df. any idea how to flatten it . – setianea Oct 03 '21 at 12:02

0 Answers0