title: Add a sequential counter column on groups to a pandas dataframe
body: <p>I feel like there is a better way than this:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  df = pd.DataFrame(
      columns=&quot;   index    c1    c2    v1 &quot;.split(),
      data= [
              [       0,  &quot;A&quot;,  &quot;X&quot;,    3, ],
              [       1,  &quot;A&quot;,  &quot;X&quot;,    5, ],
              [       2,  &quot;A&quot;,  &quot;Y&quot;,    7, ],
              [       3,  &quot;A&quot;,  &quot;Y&quot;,    1, ],
              [       4,  &quot;B&quot;,  &quot;X&quot;,    3, ],
              [       5,  &quot;B&quot;,  &quot;X&quot;,    1, ],
              [       6,  &quot;B&quot;,  &quot;X&quot;,    3, ],
              [       7,  &quot;B&quot;,  &quot;Y&quot;,    1, ],
              [       8,  &quot;C&quot;,  &quot;X&quot;,    7, ],
              [       9,  &quot;C&quot;,  &quot;Y&quot;,    4, ],
              [      10,  &quot;C&quot;,  &quot;Y&quot;,    1, ],
              [      11,  &quot;C&quot;,  &quot;Y&quot;,    6, ],]).set_index(&quot;index&quot;, drop=True)
  def callback(x):
      x['seq'] = range(1, x.shape[0] + 1)
      return x
  df = df.groupby(['c1', 'c2']).apply(callback)
  print df
  </code></pre>
  <p>To achieve this:</p>
  <pre class="lang-none prettyprint-override"><code>   c1 c2  v1  seq
  0   A  X   3    1
  1   A  X   5    2
  2   A  Y   7    1
  3   A  Y   1    2
  4   B  X   3    1
  5   B  X   1    2
  6   B  X   3    3
  7   B  Y   1    1
  8   C  X   7    1
  9   C  Y   4    1
  10  C  Y   1    2
  11  C  Y   6    3
  </code></pre>
  <p>Is there a way to do it that avoids the callback?</p>