Let´s say I have the following table:
Produced by the following python Code
import pandas as pd
data = [["Car","Sport","Wheel", 4],
["Car", "Sport","engine HP", 65],
["Car", "Sport","windows", 5],
["Car","Van","Wheel", 4],
["Car", "Van","engine HP", 85],
["Car", "Van","windows", 8],
["Truck","Small","Wheel", 4],
["Truck", "Small","engine HP", 125],
["Truck", "Small","windows", 2],
["Truck","Large","Wheel", 8],
["Truck", "Large","engine HP", 200],
["Truck", "Large","windows", 2]
]
df = pd.DataFrame(data)
#define header names
df.columns = ["Vehicle", "Type","Parameter","Value"]
df here
How do I manipulate by Dataframe to transpose the parameter value if , I don't know in advance the content of the parameter columns, or how many type of parameters there might be.
The end result would be the following table
"Vehicle","Type","Wheel","Engine","Windows"
"Car","Sport",4,65,51
"Car","Van",4,85,8
"Truck","Small",4,125,2
"Truck","Large",8,200,2