0

For example I have the next DataFrame:

a = [{'qty': 1, 'color': 'red,black,green',  'name': 'a'}, {'qty': 5, 'color': 'white',  
     'name': 'b'}, {'qty': 7, 'color': 'yellow,orange',  'name': 'c'}]
df = pd.DataFrame(a)
print(df)

enter image description here

I need to check column df['color'] and if the field contains values separated by a comma, then leave the first value, and create similar entries for all the others

I need to get the following result, screenshot below:

enter image description here

codester_09
  • 5,622
  • 2
  • 5
  • 27
LiAfe
  • 95
  • 6

0 Answers0