title: pandas get counts based on previous column
body: <p>I would like to add column to a pandas dataframe where the value is an incrementing value starting with a value from another column. For instance say I have the following dataframe.</p>
  
  <pre><code>df = pd.DataFrame([['a', 1], ['a', 1], ['b', 5], ['c', 10], ['c', 10], ['c', 10]], columns=['x', 'y'])
  df
  
      x   y
  0   a   1
  1   a   1
  2   b   5
  3   c   10
  4   c   10
  5   c   10
  </code></pre>
  
  <p>Is there some pandas functionality that would return a series that is an increasing value for each group? in other words <code>'a'</code> would start with <code>1</code>, <code>'b'</code> with <code>5</code> and <code>'c'</code> with <code>10</code>. The output series would be <code>(1, 2, 5, 10, 11, 12)</code> so it could be added to the original dataframe like so:</p>
  
  <pre><code>    x   y   z
  0   a   1   1
  1   a   1   2
  2   b   5   5
  3   c   10  10
  4   c   10  11
  5   c   10  12
  </code></pre>
  
  <p>I tried the following:</p>
  
  <pre><code>z = []
  for start, length in zip(df.y.unique(), df.groupby('x').agg('count')['y']):
      z.append(list(range(start, length + start)))
  np.array(z).flatten()
  z
  
  [[1, 2], [5], [10, 11, 12]]
  </code></pre>
  
  <p>This doesn't quite get what I need, I'm not sure why the array does not flatten and it seems overly complex for a seemingly simple task. </p>
  
  <p>EDIT: 
  The solution should be extendable to more complex dataframes as well, for instance:</p>
  
  <pre><code>df = pd.DataFrame([['a', 1], ['b', 5], ['c', 10], ['d', 5]], columns=['x', 'y'])
  df = df.append([df]*(50),ignore_index=True)
  </code></pre>
  
  <p>Where both the <code>'a'</code> and <code>'b'</code> values in column 'x' are eqaul to 5. In both of those instances the counting should start at 5</p>