title: python pandas, DF.groupby().agg(), column reference in agg()
body: <p>On a concrete problem, say I have a DataFrame DF</p>
  
  <pre><code>     word  tag count
  0    a     S    30
  1    the   S    20
  2    a     T    60
  3    an    T    5
  4    the   T    10 
  </code></pre>
  
  <p>I want to find, <strong>for every "word", the "tag" that has the most "count"</strong>. So the return would be something like</p>
  
  <pre><code>     word  tag count
  1    the   S    20
  2    a     T    60
  3    an    T    5
  </code></pre>
  
  <p>I don't care about the count column or if the order/Index is original or messed up. Returning a dictionary {<strong>'the' : 'S'</strong>, ...} is just fine.</p>
  
  <p>I hope I can do</p>
  
  <pre><code>DF.groupby(['word']).agg(lambda x: x['tag'][ x['count'].argmax() ] )
  </code></pre>
  
  <p>but it doesn't work. I can't access column information.</p>
  
  <p>More abstractly, <strong>what does the <em>function</em> in agg(<em>function</em>) see as its argument</strong>?</p>
  
  <p>btw, is .agg() the same as .aggregate() ?</p>
  
  <p>Many thanks.</p>