Situation
I have two dataframes df1 that holds some information about cars:
cars = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],
'Price': [22000,25000,27000,35000]
}
and df2 that holds media types corresponding to the cars in df1:
images = {'Brand': ['Honda Civic','Honda Civic','Honda Civic','Toyota Corolla','Toyota Corolla','Audi A4'],
'MediaType': ['A','B','C','A','B','C']
}
Expected result
In result I wanna create an overview in df1 that tells if there is a media type available for the car or not:
result = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],
'Price': [22000,25000,27000,35000],
'MediaTypeA' : [True,True,False,False],
'MediaTypeB' : [True,True,False,False],
'MediaTypeC' : [False,False,False,True]
}
How can I realize this?
I already could check if a Brand from df1 exists in df2, what tells me there is or there is no media type available at all:
df1['check'] = df1['Brand'].isin(df2['Brand'])
but I am not sure how to glue it with the check for the special media types.