title: Pandas: Group records every N days and mark duplicates
body: <p>I'd like to mark duplicate records within my data.</p>
  <p>A duplicate is defined as: for each person_key, if a person_key is repeated within 25 days of the first. However, after 25 days the count is reset.</p>
  <p>So if I had records for a person_key on Day 0, Day 20, Day 26, Day 30, the first and third would be kept, as the third is more than 25 days from the first. The second and fourth are marked as duplicate, since they are within 25 days from the &quot;first of their group&quot;.</p>
  <p>In other words, I think I need to identify groups of 25 day blocks, and then &quot;dedupe&quot; within those blocks. I'm struggling to start with to create these initial groups.</p>
  <p>I will eventually have to apply to 5m records, so am trying to steer clear of pd.DataFrame.apply</p>
  <pre><code>person_key  date    duplicate
  A   2019-01-01  False
  B   2019-02-01  False
  B   2019-02-12  True
  C   2019-03-01  False
  A   2019-01-10  True
  A   2019-01-26  False
  A   2019-01-28  True
  A   2019-02-10  True
  A   2019-04-01  False
  
  </code></pre>
  <p>Thanks for your help!</p>