I am trying to convert my input dataframe to output, i tried with stacking/unstacking. The index is 2 different columns
INPUT DATAFRAME :
id peid attr_name attr_val
1 X Type Box
1 X Color Black
2 Y Type Square
2 Y Color Red
EDIT: I used df.set_index(['id','peid','attr_name'], append=True).unstack()
The DataFrame currently :
id peid Type Color
1 X None Black
1 X Box None
2 Y None Red
2 Y Square None
REQUIRED OUTPUT DATAFRAME :
id peid Type Color
1 X Box Black
2 Y Square Red