title: Pandas - Identify Last Row by Date
body: <p>I'm trying to accomplish two things in my Pandas dataframe:</p>
  
  <ol>
  <li>Create new column <strong>Last Row</strong> ('Yes' or 'No') based on new DateCompleted</li>
  <li>Capture the <strong>next</strong> transaction on the current row, unless it's a new DateCompleted (in which case mark as Null).</li>
  </ol>
  
  <p>Original Dataset</p>
  
  <pre><code>        DateCompleted      TranNumber  Sales
  
      0   1/1/17 10:15AM     3133         130.31
      1   1/1/17 11:21AM     3531         103.12  
      2   1/1/17 12:31PM     3652         99.23  
      3   1/2/17 9:31AM      3689         83.22
      4   1/2/17 10:31AM     3701         29.93
      5   1/3/17 8:30AM      3709         31.31 
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>        DateCompleted      TranNumber   Sales    NextTranSales  LastRow
  
      0   1/1/17 10:15AM     3133         130.31   103.12         No
      1   1/1/17 11:21AM     3531         103.12   99.23          No
      2   1/1/17 12:31PM     3652         99.23    NaN            Yes
      3   1/2/17 9:31AM      3689         83.22    29.93          No 
      4   1/2/17 10:31AM     3701         29.93    NaN            Yes
      5   1/3/17 8:30AM      3709         31.31    ...            No
  </code></pre>
  
  <p>I can get the NextTranSales based on: </p>
  
  <pre><code> df['NextTranSales'] = df.Sales.shift(-1)
  </code></pre>
  
  <p>But I'm having trouble determining the last row in the DateCompleted group and marking NextTranSales as Null if it is the last row. </p>
  
  <p>Thanks for your help!</p>