How to group the groups

machine_learning
group_by

#1

Hello everybody,

I need your help to group all groups who have the same product. Every Group have more than one product but every product belongs just to one group. This problem looks at the beginning so easy but it s hard to handel (at least for me :slight_smile: ).
I neet to have a list of all groups who are the same like adding (Concatenate them or whatever)
Thanks in advance !

Best Regards
MED


#2

Hi @med25,

could you share the first few rows of the dataset?


#3

Group Product

G1 P1
G1 P2
G2 P3
G2 P1
G3 P5
G3 P6
G4 P5
G4 P4

Result:
Grouping 1: G1G2
Grouping 2: G3G4


#4

to be more clear how to group a list of collections that have common values
For example
List input:
X;Y
Y;Z
W;P
P;O

Output
X;Y;Z
W;P;O


#5

Hello @med25,
this seems to be more like an Union operation rather grouping. Can you try a solution from:

or if there is actual grouping required - then Pivot table can be implemented on pandas dataframe, e.gโ€ฆ

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.pivot_table.html

check it one and let us know if it solves your purpose.