I have a dataframe where one of the columns contains a list. I want to break up these lists so that each element has its own row.
Ex df:
index Name Color
1 Ford ['Red,Blue' , 'Red,Blue']
result df:
index Name Color
1 Ford Red
2 Ford Blue
3 Ford Red
4 Ford Blue
The code that I tried:
s = df['Color'].str.split(',').apply(Series,1).stack()
s.index = s.index.droplevel(-1)
s.name = 'Color'
del df['Color']
df = df.join(s)