0

This is a simple example of the problem in hand, if I have the following table

df1
  Column1  Column2 Column3
0     cat        a       1
1     dog        b       4
2     cat        b       2
3     bird       a       3
4     cat        a       2
5     dog        b       3

I want to get all the rows that are duplicated regarding Column1 and Column2.

my take on that was as follows:

df1[df1['Column1'].isin(df1[df1[['Column1','Column2']].duplecated()]['Column1]) & df1['Column2'].isin(df1[df1[['Column1','Column2']].duplecated()]['Column2])]

Which have an output of

  Column1  Column2 Column3
0     cat        a       1
1     dog        b       4
2     cat        b       2
4     cat        a       2
5     dog        b       3

While the desired output should be

  Column1  Column2 Column3
0     cat        a       1
1     dog        b       4
4     cat        a       2
5     dog        b       3

0 Answers0