I have a df where some values are added to the same row like this fake df:
[['Apple, Kiwi, Clementine', np.nan , 'Cycling', 5],
['Kiwi', 'Blue', np.nan , 20],
['Banana, Clementine', np.nan , 'Hockey', 12],
['Apple', 'Purple', 'Triathlon', 15],
['Kiwi', np.nan, 'Swimming', 8]]),
columns=['fruit', 'colour', 'sport', 'wins'])
What I would like is to duplicate the rows with multiple fruits while splitting the first entry to contain only one fruit.
In the end I want to plot the average wins per fruit. So if there is a way of grouping where each fruit mentioned is grouped with the correct fruit so to speak that would also work.
I have tried some string manipulation but then it is simply split up and the values in the other columns not duplicated. It is quite frustrating since I know how to do it in r but am a beginner in python.