Situation
I have a dataframe attributes
that holds some attribute information about cars in 3 series:
attributes = {'brand': ['Honda Civic','Honda Civic','Honda Civic','Toyota Corolla','Toyota Corolla','Audi A4'],
'attributeName': ['wheels','doors','fuelType','wheels','color','wheels'],
'attributeValue': ['4','2','hybrid','4','red','4']
}
Expected result
result = {'brand': ['Honda Civic','Toyota Corolla','Audi A4'],
'wheels': ['4','4','4'],
'doors': ['2','',''],
'fuelType':['hybrid','',''],
'color': ['','red','']
}
How can I realize this?
Transform the values from attributeName
into series to represent its attributeValue
for each brand/car in one row.
With get_dummies
I get this transformation, but only with true/false values not with the original values.