title: python pandas reattach column after aggregation
body: <p>My DataFrame looks like this</p>
  
  <pre><code>exams = pd.DataFrame({'id1':['1x', '1x','2x','3x','3x'], 'id2':['a','a','b','a','a'],'data':[1,2,3,4,5]}) 
  
      id1    id2   data
  0    1x      a      1
  1    1x      a      2
  2    2x      b      3
  3    3x      a      4
  4    3x      a      5
  </code></pre>
  
  <p>Then I aggregate it to</p>
  
  <pre><code>exams_agg = exams.groupby('id1').agg('mean')
  </code></pre>
  
  <p>Then <code>exams_agg</code> looks like </p>
  
  <pre><code>       data
  id1
   1x      1.5
   2x        3
   3x      4.5
  </code></pre>
  
  <p>I want to reattach <code>id2</code> column to <code>exams_agg</code>. So I was thinking about create a lookup table </p>
  
  <pre><code>lookup = exams[['id1', 'id2']]
  exams_agg = pd.merge(exams_agg, lookup, left_index=True, right_on='id1')
  </code></pre>
  
  <p>But since <code>lookup</code> contains duplicate pairs of ids, <code>exams_agg</code> contains duplicates as well. What is a good way to create</p>
  
  <pre><code>       data    id2
  id1
   1x      1.5     a
   2x        3     b
   3x      4.5     a
  </code></pre>