title: Pandas get first and last value of column from group
body: <p>Hi I have <code>dataframe</code> that contains multiple rows for the same ID. One of the columns is a Date (in ascending order). I want to calculate the date difference between the first entry and last.</p>
  
  <p>I am doing this by instantiating a pandas constructor as follows:</p>
  
  <pre><code>g = df.groupby('ID')
  
  print(pd.DataFrame({'first':g.Date.nth(0), 'last':g.Date.nth(-1)}))
  </code></pre>
  
  <p>The first value is correct, however, the last value is nowhere near correct.</p>
  
  <p>For example, for a specific id, the <code>first date</code> is <code>2000-05-08</code> and the <code>last date</code> is <code>8/21/2010</code>. The result outputted is:  </p>
  
  <pre><code>               first       last
  ID                         
  31965.0        2000-05-08  2002-12-29
  </code></pre>
  
  <p><code>2002-12-29</code> is somewhere in the middle.</p>
  
  <p>Sample Data:</p>
  
  <pre><code>ID  Date
  31965   5/8/2000
  31965   5/10/2000
  31965   5/18/2000
  31965   5/22/2000
  31965   5/23/2000
  31965   5/25/2000
  31965   5/30/2000
  31965   6/7/2000
  31965   6/8/2000
  31965   6/11/2000
  31965   6/13/2000
  .....
  31965   4/11/2009
  31965   5/9/2009
  31965   5/16/2009
  31965   5/23/2009
  31965   2/5/2010
  31965   2/26/2010
  31965   3/13/2010
  31965   4/10/2010
  31965   8/21/2010
  </code></pre>
  
  <p>I want my result for ID 31965 to be: 5/8/2000 and 8/21/2010 so that I can eventually work out the date difference.</p>