I am trying to get the ratio between rows that share the same variable except one:
Dataframe example:
Brand Model Color Insured Price
------------------------------------------
X Y Red True 10
X Y Red False 11
Z W Black True 15
Z W Black False 18
Output:
Brand Model Color Insured Price Ratio
-------------------------------------------------
X Y Red True 10 1
X Y Red False 11 1.1
Z W Black True 15 1
Z W Black False 18 1.2
So I want to separate each product and divide the prices based on the "True" value for insured.
I thought about doing a join on the Brand, Model, and Color, but don't know where to go from there.
df_product = df_product.merge(df, on=['Brand','Model','Color'], how = "left")
How could I do the above?
Thanks