title: Returning a value from dataframe using columns as a range
body: <p>Factor Dataframe:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Code</th>
  <th>Min</th>
  <th>Max</th>
  <th>Factor</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>A</td>
  <td>0</td>
  <td>100</td>
  <td>1</td>
  </tr>
  <tr>
  <td>A</td>
  <td>101</td>
  <td>300</td>
  <td>2</td>
  </tr>
  <tr>
  <td>A</td>
  <td>301</td>
  <td>800</td>
  <td>3</td>
  </tr>
  <tr>
  <td>A</td>
  <td>800</td>
  <td>NaN</td>
  <td>4</td>
  </tr>
  <tr>
  <td>B</td>
  <td>0</td>
  <td>100</td>
  <td>2</td>
  </tr>
  <tr>
  <td>B</td>
  <td>101</td>
  <td>300</td>
  <td>4</td>
  </tr>
  <tr>
  <td>B</td>
  <td>301</td>
  <td>800</td>
  <td>6</td>
  </tr>
  <tr>
  <td>B</td>
  <td>800</td>
  <td>NaN</td>
  <td>8</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The table above is used to return a factor based on two values, the 'Code' and a specific number. A specific value is provided, such as 5, 302, 253, 8000 and if that value falls between the min and max, the factor is returned.</p>
  <p>For example:</p>
  <ul>
  <li>A, 355 = 3</li>
  <li>B, 9000 = 8</li>
  </ul>
  <p>I have a separate table with several thousand lines with values which need to have the factor assigned.</p>
  <p>Dataframe:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Item</th>
  <th>Code</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>001</td>
  <td>A</td>
  <td>1</td>
  </tr>
  <tr>
  <td>002</td>
  <td>A</td>
  <td>322</td>
  </tr>
  <tr>
  <td>003</td>
  <td>B</td>
  <td>21</td>
  </tr>
  <tr>
  <td>004</td>
  <td>A</td>
  <td>342</td>
  </tr>
  <tr>
  <td>005</td>
  <td>A</td>
  <td>32</td>
  </tr>
  <tr>
  <td>006</td>
  <td>B</td>
  <td>7666</td>
  </tr>
  <tr>
  <td>007</td>
  <td>B</td>
  <td>10000</td>
  </tr>
  <tr>
  <td>008</td>
  <td>B</td>
  <td>86</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>How do you use the pandas tool set to return the desired factor and append the relevant factor as a new column?</p>