Home > Software design >  gather element that share infomation with pandas
gather element that share infomation with pandas

Time:10-07

My task is to gather element that share something in common.

Example:

pd.DataFrame({'C1': ['A', 'B', 'C', 'D', 'R', 'X'], 'C2': ['B', 'C', 'D', 'E', 'S', 'Y']})
    C1  C2
0   A   B
1   B   C
2   C   D
3   D   E
4   R   S
5   X   Y

and This is what I'm looking for:

    Groups
0   [A, B, C, D, E]
1   [R, S]
2   [X, Y]

Any Idea ?

CodePudding user response:

You should use enter image description here

  • Related