I have a raw data like this and I want to create a new transaction data frame group by customer_id like this
How should I do in python? Pleaseeeee~
I have a raw data like this and I want to create a new transaction data frame group by customer_id like this
How should I do in python? Pleaseeeee~
nisawaras, welcome to community (in the future the questions should be more precise)
data = {'customer_id': [1,1,2 ], 'menu_id': ['Cake','Water','Candy']}
df = pd.DataFrame(data)
grouped = df.groupby(['customer_id'])['menu_id'].apply(', '.join).reset_index()
grouped
output: