title: Mapping ranges of values in pandas dataframe
body: <p>Apologies if this has been asked before, but I looked extensively without results.</p>
  
  <pre><code>import pandas as pd    
  import numpy as np    
  df = pd.DataFrame(data = np.random.randint(1,10,10),columns=['a'])    
  
     a
  0  7
  1  8
  2  8
  3  3
  4  1
  5  1
  6  2
  7  8
  8  6
  9  6
  </code></pre>
  
  <p>I'd like to create a new column <code>b</code> that maps several values of <code>a</code> according to some rule, say a=[1,2,3] is 1, a = [4,5,6,7] is 2, a = [8,9,10] is 3. one-to-one mapping is clear to me, but what if I want to map by a list of values or a range?</p>
  
  <p>I tought along these lines...</p>
  
  <pre><code>df['b'] = df['a'].map({[1,2,3]:1,range(4,7):2,[8,9,10]:3})
  </code></pre>