title: Ordering value in DataFrame based on pre-defined percentage groups
body: <p>I have the following sample dataframe</p>
  
  <pre><code>df = pd.DataFrame({'ID': [11, 12, 16, 19, 14, 9, 4, 13, 6, 18], 
                     'Value': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
  </code></pre>
  
  <p>to which I add the percentage of the <code>Value</code> using </p>
  
  <pre><code>df['Percent Value'] = df.reset_index()['Value'].rank(method='dense', pct=True)
  </code></pre>
  
  <p>which gives</p>
  
  <pre><code>    ID  Value   Percent Value
  0   11   1         0.1
  1   12   2         0.2
  2   16   3         0.3
  3   19   4         0.4
  4   14   5         0.5
  5   9    6         0.6
  6   4    7         0.7
  7   13   8         0.8
  8   6    9         0.9
  9   18   10        1.0
  </code></pre>
  
  <p>I then define the following percentage array</p>
  
  <pre><code>percentage = np.array([30, 40, 60, 90, 100])
  </code></pre>
  
  <p>My desired output is the following with an <code>Order</code> column where, based on the <code>percentage</code> array, the <code>Value</code> which are up to 30% gets order 1, 30-40% gets order 2, 40-60% gets order 3, 60-90% gets order 4, 90-100% gets order 5. </p>
  
  <p>So the final output is</p>
  
  <pre><code>    ID  Value   Percent Value   Order
  0   11   1          0.1           1
  1   12   2          0.2           1
  2   16   3          0.3           1
  3   19   4          0.4           2
  4   14   5          0.5           3
  5   9    6          0.6           3
  6   4    7          0.7           4
  7   13   8          0.8           4
  8   6    9          0.9           4
  9   18   10         1.0           5
  </code></pre>
  
  <p>I can do this by looping over the <code>Percent Value</code> column and taking the index of the first value in <code>percentage</code> array which returns <code>True</code> for <code>&lt;</code> condition. I am wondering if there is some simpler way in pandas where I can pass <code>percentage</code> array as the argument to compare the <code>Percent Value</code> column. </p>
  
  <p><strong>My attempt</strong> using list comprehension</p>
  
  <pre><code>df['Order'] = [1 + np.where(v &lt;= percentage)[0][0] for v in df['Percent Value']]
  </code></pre>