title: How can I know which are the duplicated rows in a Pandas Data Frame?
body: <p>I am working with Pandas and the function <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.duplicated.html" rel="nofollow noreferrer"><code>duplicated()</code></a> to detect which rows are equal:</p>
  
  <pre><code>import pandas as pd
  
  d = {
      1: {'name': 'n1', 1: 10, 2: 20, 3: 30},
      2: {'name': 'n2', 1: 10, 2: 20, 3: 30},
      3: {'name': 'n3', 1: 11, 2: 21, 3: 30},
      4: {'name': 'n4', 1: 11, 2: 21, 3: 30},
      5: {'name': 'n5', 1: 12, 2: 22, 3: 30},
      6: {'name': 'n6', 1: 13, 2: 22, 3: 30},
      7: {'name': 'n7', 1: 14,        3: 35},
      8: {'name': 'n8',        2: 22, 3: 35},
  }
  pd.DataFrame.from_dict(d).transpose().set_index('name')
  </code></pre>
  
  <p>This gives me a nice data frame like this one:</p>
  
  <pre><code>          1    2   3
  name              
  n1       10   20  30    # same as n2
  n2       10   20  30    # same as n1
  n3       11   21  30    # same as n4
  n4       11   21  30    # same as n3
  n5       12   22  30
  n6       13   22  30
  n7       14  NaN  35
  n8      NaN   22  35
  </code></pre>
  
  <p>Now I want to group those lines whose columns are the same. That is, I want Pandas to tell me that the rows <code>n1</code> and <code>n2</code> are equal, and so <code>n3</code> and <code>n4</code> are.</p>
  
  <p>Using <code>duplicated()</code> I get some interesting results:</p>
  
  <pre><code>df[df.duplicated(keep=False)]
           1   2   3
  name            
  n1      10  20  30
  n2      10  20  30
  n3      11  21  30
  n4      11  21  30
  </code></pre>
  
  <p>Which is correct, since it shows those rows that have duplicated. However, my aim is to get to know which are those columns, as well as knowing which are the tuples of duplicates. That is, I would need a result on the form of <code>[(n1, n2), (n3,n4)]</code>, a list with the duplicates one to each other. List, dict, anything works to me as well as it has this info.</p>
  
  <p>I have been browsing through Pandas' documentation and cannot find something like this. I tried a bit with <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html" rel="nofollow noreferrer"><code>groupby()</code></a>, but nothing reasonable comes up.</p>