I have a dataframe called cars. I want to create a new column called 'Brand_name' with just the first element of the brand column but I keep getting error message 'list index out of range'
cars = Brand Units_sold
[Toyota] 87
[Acura] 99
[Toyota, Ford, GMC] 87
[Kia, Honda] 25
[Honda] 109
[Mercedes, Bugatti] 76
......
Here is what I what to achieve
cars = Brand Units_sold Brand_name
[Toyota] 87 [Toyota]
[Acura] 99 [Acura]
[Ford,Toyota, GMC] 87 [Ford]
[Kia, Honda] 25 [Kia]
[Honda] 109 [Honda]
[Mercedes, Bugatti] 76 [Mercedes]
....
Here is the code I applied
cars['Brand_name'] = cars['Brand'].apply(lambda x: x[0])