title: create column with buckets based on value range in another column python
body: <p>I have a sample df</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A</th>
  <th>B</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>X</td>
  <td>30</td>
  </tr>
  <tr>
  <td>Y</td>
  <td>150</td>
  </tr>
  <tr>
  <td>Z</td>
  <td>450</td>
  </tr>
  <tr>
  <td>XX</td>
  <td>300</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to create another column C that buckets column B based on some breakpoints</p>
  <p>Breakpts = [50,100,250,350]</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A</th>
  <th>B</th>
  <th>C</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>X</td>
  <td>30</td>
  <td>'0-50'</td>
  </tr>
  <tr>
  <td>Y</td>
  <td>150</td>
  <td>'100-250'</td>
  </tr>
  <tr>
  <td>Z</td>
  <td>450</td>
  <td>'&gt;350'</td>
  </tr>
  <tr>
  <td>XX</td>
  <td>300</td>
  <td>'250-350'</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I have the following code that works</p>
  <pre><code>def conditions(i): 
      if i &lt;=50: return '0-50'
      if i &gt; 50 and i &lt;=100: return '50-100'
      if i &gt; 100 and i &lt;=250: return '100-250'
      if i &gt; 250 and i &lt;=350: return '250-350'
      if i &gt; 350: return '&gt;350'
  
  df['C']=df['B'].apply(conditions)
  </code></pre>
  <p>However I would like to make the breakpts dymanic. So if I use a different breakpts like [100,250,300,400] the code should automatically create different buckets based on the breakpts.</p>
  <p>Any ideas on how to do this?</p>