title: Remove non-duplicated rows from pandas
body: <p>This is rather simple but I can't get me head around it. Let's say for the following data frame, I want to keep only the rows with duplicated values in column y:</p>
  
  <pre><code>&gt;&gt;&gt; df
     x  y
      x   y
  0   1   1
  1   2   2
  2   3   2
  3   4   3
  4   5   3
  5   6   3
  6   7   5
  7   8   2
  </code></pre>
  
  <p>The desired output looks like:</p>
  
  <pre><code>&gt;&gt;&gt; df
      x   y
  1   2   2
  2   3   2
  3   4   3
  4   5   3
  5   6   3
  7   8   2
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>df[~df.duplicated('y')]
  </code></pre>
  
  <p>but I get this:</p>
  
  <pre><code>    x   y
  0   1   1
  1   2   2
  3   4   3
  6   7   5
  </code></pre>