title: Pandas: Difference between largest and smallest value within group
body: <p>Given a data frame that looks like this</p>
  
  <pre><code>GROUP VALUE
    1     5
    2     2
    1     10
    2     20
    1     7
  </code></pre>
  
  <p>I would like to compute the difference between the largest and smallest value within each group. That is, the result should be</p>
  
  <pre><code>GROUP   DIFF
    1      5
    2      18
  </code></pre>
  
  <p>What is an easy way to do this in Pandas?</p>
  
  <p>What is a fast way to do this in Pandas for a data frame with about 2 million rows and 1 million groups?</p>