Assume I have a dataframe similar to:
A B
0 [ab, cd] 1
1 [cd, de] 2
2 [de, ef] 1
3 [gh] 1
I am now interested in finding all "duplicate" entries when splitting it up by using .explode("A"). Using explode() I get the following output:
A B
0 ab 1
0 cd 1
1 cd 2
1 de 2
2 de 1
2 ef 1
3 gh 1
I would like to get the position of all rows where the index is more than once (i.e. the rows with indices [0, 1, 2]). One option would be of course to iterate over all rows and check if I get multiple rows when calling df.loc[i], but I could imagine this being very slow. Are there faster in-built options, ideally mapping the returned rows to the "real" row indices?
I.e. calling df.loc[0] would return
A B
0 ab 1
0 cd 1
and in addition to that, I would be interested in the "real" indices, here being [0, 1]. How could I achieve that?