title: Create a sequential number (counter) for rows within each group of a dataframe
body: <p>How can we generate unique id numbers within each group of a dataframe? Here's some data grouped by "personid":</p>
  
  <pre><code>personid date measurement
  1         x     23
  1         x     32
  2         y     21
  3         x     23
  3         z     23
  3         y     23
  </code></pre>
  
  <p>I wish to add an id column with a unique value for each row within each subset defined by "personid", always starting with <code>1</code>. This is my desired output:</p>
  
  <pre><code>personid date measurement id
  1         x     23         1
  1         x     32         2
  2         y     21         1
  3         x     23         1
  3         z     23         2
  3         y     23         3
  </code></pre>
  
  <p>I appreciate any help.</p>