title: Pandas self-join on non-unique values
body: <p>I have the following table:</p>
  
  <pre><code>       ind_ID  pair_ID orig_data
  0           A        1         W 
  1           B        1         X
  2           C        2         Y
  3           D        2         Z
  4           A        3         W          
  5           C        3         X          
  6           B        4         Y          
  7           D        4         Z          
  </code></pre>
  
  <p>Each row has an <code>individual_ID</code>, and a <code>pair_ID</code> that it shares with exactly one other row. I want to do a self join, so that every row has its original data, and the data of the row it shares a <code>pair_ID</code> with:</p>
  
  <pre><code>       ind_ID  pair_ID orig_data partner_data
  0           A        1         W            X
  1           B        1         X            W
  2           C        2         Y            Z
  3           D        2         Z            Y
  4           A        3         W            X
  5           C        3         X            W
  6           B        4         Y            Z
  7           D        4         Z            Y
  </code></pre>
  
  <p>I have tried:</p>
  
  <pre><code>df.join(df, on='pair_ID')
  </code></pre>
  
  <p>But obviously since <code>pair_ID</code> values are not unique I get:</p>
  
  <pre><code>       ind_ID  pair_ID orig_data partner_data
  0           A        1         W          NaN
  1           B        1         X          NaN
  2           C        2         Y          NaN
  3           D        2         Z          NaN
  4           A        3         W          NaN
  5           C        3         X          NaN
  6           B        4         Y          NaN
  7           D        4         Z          NaN 
  </code></pre>
  
  <p>I've also thought about creating a new column that concatenates <code>ind_ID+pair_ID</code> which would be unique, but then the join would not know what to match on.</p>
  
  <p>Is it possible to do a self-join on <code>pair_ID</code> where each row is joined with the matching row that is not itself?</p>