title: Compare dataframe value with key range in dictionary and return value
body: <p>I'm trying to compare a value in a dataframe with key ranges in a dictionary and grab the corresponding dictionary value.
  Been looking at loop and iterations, however, as a beginner, can't get it working.</p>
  
  <p>Example:</p>
  
  <pre><code>import pandas as pd
  
  colors = {range(0,50):"red",range(50,100):"blue",
            range(100,150):"green",range(150,200):"orange"
            ,range(200, 250):"purple", range(250,1000):"grey"}
  
  df = pd.DataFrame(data=[51,8,265,167], columns=['A'])
  </code></pre>
  
  <p>The result I'm looking for:</p>
  
  <pre><code>    A     color
  0   51    blue
  1   8     red
  2   265   grey
  3   167   orange
  </code></pre>
  
  <p>This is my basic idea (used a hard coded value):</p>
  
  <pre><code>for (start, end), value in colors.items():
      if start &lt;= 85 &lt; end:
          print(value) #add retrieved value to dataframe
  </code></pre>
  
  <p>I guess I could use a comprehension and/or a lambda function but again, I'm a beginner.</p>