title: mark last record in group by date pandas python
body: <p>I want to mark the last record in group
  ['ru','case','opdate']
  based on 'lst_svc'</p>
  
  <p>Here is my attempt (problematic because the duplicate is counted twice).</p>
  
  <pre><code>import pandas as pd
  from datetime import datetime
  
  # Create Dateframe
  d = {'ru'     : pd.Series([1., 1., 1., 1., 3, 3]),
       'case'   : pd.Series([2., 2., 2., 2., 2, 2]),
       'opdate' : pd.Series([datetime(2012, 5, 2), datetime(2012, 5, 2), datetime(2012, 5, 2),datetime(2012, 5, 2), datetime(2012, 5, 3),datetime(2012, 5, 3)]),
       'lst_svc': pd.Series([datetime(2012, 5, 2), datetime(2012, 5, 3), datetime(2012, 5, 5),datetime(2012, 5, 5),datetime(2012, 6, 5),])}
  
  df = pd.DataFrame(d)
  
  # Mark last
  df['lastMark'] = (df.groupby(['ru','case','opdate'])['lst_svc'].transform(max) == df['lst_svc']).astype(int)
  </code></pre>
  
  <p>The DataFrame looks like this:</p>
  
  <pre><code>   case    lst_svc     opdate   ru
  0   2.0 2012-05-02 2012-05-02  1.0
  1   2.0 2012-05-03 2012-05-02  1.0
  2   2.0 2012-05-05 2012-05-02  1.0
  3   2.0 2012-05-05 2012-05-02  1.0
  4   2.0 2012-06-05 2012-05-03  3.0
  5   2.0        NaT 2012-05-03  3.0
  </code></pre>
  
  <p>The (wrong) result of my code looks like this:</p>
  
  <pre><code>   case    lst_svc     opdate   ru  lastMark
  0   2.0 2012-05-02 2012-05-02  1.0         0
  1   2.0 2012-05-03 2012-05-02  1.0         0
  2   2.0 2012-05-05 2012-05-02  1.0         1
  3   2.0 2012-05-05 2012-05-02  1.0         1
  4   2.0 2012-06-05 2012-05-03  3.0         1
  5   2.0        NaT 2012-05-03  3.0         0
  </code></pre>