title: iterate over unique values in PANDAS
body: <p>I have a dataset in the following format:</p>
  
  <pre><code>Patient  Date       colA  colB
  1        1/3/2015   .     5
  1        2/5/2015   3     10
  1        3/5/2016   8     .
  2        4/5/2014   2     .
  2        etc
  </code></pre>
  
  <p>I am trying to define a function in PANDAS which treats unique patients as an item and iterates over these unique patient items to keep only to most recent observation per column (replacing all other values with missing or null). For example: for patient 1, the output would entail -</p>
  
  <pre><code>Patient  Date       colA  colB
  1        1/3/2015   .     .
  1        2/5/2015   .     10
  1        3/5/2016   8     .
  </code></pre>
  
  <p>I understand that I can use something like the following with .apply(), but this does not account for duplicate patient IDs...</p>
  
  <pre><code>def getrecentobs():
      for i in df['Patient']:
          etc
  </code></pre>
  
  <p>Any help or direction is much appreciated.</p>