i j
1 2
1 3
3 2
4 5
5 6
7 8
9 10
. .
. .
. .
101 1
102 105
102 4
Each row in the above table represents a person. The columns of i and j are identifiers of the person and belong only to that person. These identifiers show up in multiple rows therefore a row containing the same identifier of another row would mean those two rows represent the same person, and also the paired identifiers in those rows belong to that person. For instance, row one contains 1 and 2, and row two contains 1 and 3. Since 1 exists in both these rows that means 1,2, and 3 are identifiers of that person. A person can have any number of rows.
I am looking for an efficient classification algorithm which will group all identifiers together and assign a unique id representing the individual assigned to these IDs. This is a type of discrete chain classification problem. Is there a type of algorithm or classification practice I should be looking into to help solve my problem. I am also working in python and pandas if there is known library.