I have the following data
Date Name Salary Models
01/01/2019 Jack 50,000 AC, GM, MC
01/01/2019 Sam 30,000 AC, KL
01/01/2019 Los 45,000 GM
I need to transpose the column Models but each model(separated by comma) should be a column. Expected output is
Date Name Salary AC GM MC KL GM
01/01/2019 Jack 50,000 1 1 1 0 0
01/01/2019 Sam 30,000 1 0 0 1 0
01/01/2019 Los 45,000 0 0 0 0 1
I tried the pandas.dummies.
df1 = pandas.get_dummies(df, columns=['Models'])
But the problem is I don't know how to split the models in each row based on the comma and then do the pandas.dummies. Your help is much appreciated.
GMcolumns, and the last row doesn't have any1's.