I want to combine multiple columns of text from multiple row groups. I know that the join joins into a single cell but it doesn't read by product. I want a single cell to have the information for that product in different brands and continents by the plan. For example: Within the laptop product what are the brands and continents in plan 1, in plan 2 , 3 and so on?
df['all'] = df[['product', 'brand', ...]].agg('-'.join, axis=1)
Here the dataframe:
product brand continent plan
laptop lg n_am P1
laptop samsung n_am P1
laptop apple eu P3
tv lg eu P3
tv samsung eu P2
tv apple n_am P2
tv samsung n_am P1
cellphone lg eu P3
cellphone apple n_am P2
cellphone apple eu P1
Expected dataframe:
product brand continent plan all
laptop lg n_am P1 product: laptop; plan: P1; brand: lg-samsung; continent: n_am
laptop samsung n_am P1 product: laptop; plan: P1; brand: lg-samsung; continent: n_am
laptop apple eu P3 product: laptop; plan: P3; brand: apple; continent: eu
tv lg eu P3 product: tv; plan: P3; brand: lg; continent: eu
tv samsung eu P2 product: tv; plan: P2; brand: samsung-apple; continent: n_am-eu
tv apple n_am P2 product: tv; plan: P2; brand: samsung-apple; continent: n_am-eu
tv samsung n_am P1 product: tv; plan: P1; brand: samsung; continent: n_am
cellphone lg eu P3 product: cellphone; plan: P3; brand: lg; continent: eu
cellphone apple n_am P2 product: cellphone; plan: P2; brand: apple; continent: n_am
cellphone apple eu P1 product: cellphone; plan: P1; brand: apple; continent: eu