title: Python Pandas max value in a group as a new column
body: <p>I am trying to calculate a new column which contains maximum values for each of several groups. I'm coming from a Stata background so I know the Stata code would be something like this:</p>
  
  <pre><code>by group, sort: egen max = max(odds) 
  </code></pre>
  
  <p>For example: </p>
  
  <pre><code>data = {'group' : ['A', 'A', 'B','B'],
      'odds' : [85, 75, 60, 65]}
  </code></pre>
  
  <p>Then I would like it to look like:</p>
  
  <pre><code>    group    odds    max
       A        85      85
       A        75      85
       B        60      65
       B        65      65
  </code></pre>
  
  <p>Eventually I am trying to form a column that takes <code>1/(max-min) * odds</code> where <code>max</code> and <code>min</code> are for each group. </p>