I have the dataframe below:
details = {
'container_id' : [1, 2, 3, 4, 5, 6 ],
'container' : ['black box', 'orange box', 'blue box', 'black box','blue box', 'white box'],
'fruits' : ['apples, black currant', 'oranges','peaches, oranges', 'apples','apples, peaches, oranges', 'black berries, peaches, oranges, apples'],
}
# creating a Dataframe object
df = pd.DataFrame(details)
I want to find the frequency of each fruit separately on a list.
I tried this code
df['fruits'].str.split(expand=True).stack().value_counts()
but I get the black count 2 times instead of 1 for black currant and 1 for black berries.