DataFrame:
Name Category Port Class
A Code 443 string1
A Code 80 string2
B Math 443 string3
A Code 443 string1
B Math 80 string4
Code that I have tried:
df1 = df.name.ne(df.name.shift())
count = df.name.groupby(df1.cumsum()).size()
Output that I got:
Name Category Port Class Count
A Code 443 string1 2
B Math 443 string3 1
A Code 443 string1 1
B Math 80 string4 1
The output that I want:
Name Category Port Class Count
A Code 443, 80 string1, string2 2
B Math 443 string3 1
A Code 443 string1 1
B Math 80 string4 1
Any help is appreciated.