Suppose the dataframe is as follows:
id class count
0 A 2
0 B 2
0 C 2
0 D 1
1 A 3
1 B 3
1 E 2
2 D 4
2 F 2
For each id, I want to find the class whose count is the maximum. If more than one class have the same count, merge them into one line. For the above example, the result should be as follows:
id class count
0 A,B,C 2
1 A,B 3
2 D 4
How to use a statement in pandas to realize this function?