title: Keeping the N first occurrences of
body: <p>The following code will (of course) keep only the first occurrence of 'Item1' in rows sorted by 'Date'. Any suggestions as to how I could get it to keep, say the first 5 occurrences?</p>
  
  <pre><code>## Sort the dataframe by Date and keep only the earliest appearance of 'Item1'
  ## drop_duplicates considers the column 'Date' and keeps only first occurence
  
  coocdates = data.sort('Date').drop_duplicates(cols=['Item1'])
  </code></pre>