title: How to assign a column value based on number of rows in that group
body: <p>Create some test data:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  ID = pd.DataFrame(np.random.randint(0,1000000,size=(100, 1)), columns=['ID'])
  Prob = pd.DataFrame(np.random.randint(0, 100,size=(100, 1)), columns=['Probability'])/100
  
  
  cuts = [{'flag': 'L', 'cut': 44},
           {'flag': 'M', 'cut': 31},
           {'flag': 'H', 'cut': 25}]
  
  cuts = pd.DataFrame(cuts)
  
  df = pd.concat([ID.reset_index(drop=True), Prob], axis=1)
  df = df.sort_values(by=['Probability'])
  df["flag"] = np.nan
  </code></pre>
  
  <p>I have two datasets I am working with, one is a list of probabilities from a predictive model, the other is a list of cut points calculated based on the length of the list it's given. I would like to find an efficient way to assign these values to the 'flag' column of df.</p>
  
  <p>For this example, the first 44 rows would be assigned 'L', the next 31 rows will be assigned 'M' and the last 25 rows will be assigned 'H'</p>
  
  <p>My environment is with many more different flag values and millions of rows but for simplicity I am using 100 rows and 3 flags in the example.</p>
  
  <p>How do I assign these flags using 'the next x number of rows' and not the index or some other reference key? </p>