I am trying to pivot rows "attribute_code" dataframe which currently looks like this:
d2 = {'attribute': ['ID', 'description', "name", "ID", "description", "name"],
'value': [123, "wine", "green wine", 124, "cola", "colaPlant"]
}
df2 = pd.DataFrame(data=d2)
Output:
attribute value
0 ID 123
1 description wine
2 name green wine
3 ID 124
4 description cola
5 name colaPlant
when I'm trying to pivot the column "attributes" I get:
ID description name
0 123 nan nan
1 nan wine nan
2 nan nan green wine
3 124 nan nan
4 nan cola nan
5 nan nan colaPlant
but instead I want:
ID description name
0 123 wine green wine
1 124 cola colaPlant
how do I manage to get it? I tried also transposing the column but it won't work, I got only a flat row.