title: How to add columns to a pandas Dataframe that has row filled with range based on a column value
body: <p>I created a df and then repeated rows in that df based on values in a column. For example:</p>
  
  <pre><code>df = pd.DataFrame({
          'a': [1,2,3],
          'b': ['x','y','z']
          })
  </code></pre>
  
  <p>Then I repeated the rows based on a col value like this:</p>
  
  <pre><code>df = df.loc[df.index.repeat(df['a'])]   
  </code></pre>
  
  <p>and I got:</p>
  
  <pre><code>df
  Out[150]: 
     a  b
  0  1  x
  1  2  y
  1  2  y
  2  3  z
  2  3  z
  2  3  z
  </code></pre>
  
  <p>Now I want to add another column with values having increment count based on a  column values (in this case values from column a),
  The desired output is:</p>
  
  <pre><code>df
  Out[150]: 
     a  b  c
  0  1  x  1
  1  2  y  1
  1  2  y  2
  2  3  z  1
  2  3  z  2
  2  3  z  3
  </code></pre>
  
  <p>How can I do this. Range function doesn't work in a vectorized fashion, so I need help. Thanks.</p>