d = {'Location':['Fridge','Fridge','Pantry','Pantry'], 'Food': ['Juice','Ham','Rice','Oil']}
df = pd.DataFrame(d)
I want to create a new DataFrame that groups all the Locations but combines their respective foods. So under 'Fridge' I would see 'Juice, Ham'. Groupby seems the logical function, but I can't get the foods combined.
source https://stackoverflow.com/questions/75464197/grouping-dataframe-combining-column-values
Comments
Post a Comment