title: Approach to speed up pandas multilevel index selection?
body: <p>I have a data frame, and would like to work on a small partition each time for particular  tuples of values of <code>'a', 'b','c'</code>.</p>
  
  <pre><code>df = pd.DataFrame({'a':np.random.randint(0,10,10000),
                     'b':np.random.randint(0,10,10000),
                     'c':np.random.randint(0,10,10000),
                     'value':np.random.randint(0,100,10000)})
  </code></pre>
  
  <p>so I chose to use pandas multiindex:</p>
  
  <pre><code>dfi = df.set_index(['a','b','c'])
  dfi.sortlevel(inplace = True)
  </code></pre>
  
  <p>However, the performance is not great.</p>
  
  <pre><code>%timeit dfi.ix[(2,1,7)] # 511 us
  %timeit df[(df['a'].values == 2) &amp; 
             (df['b'].values == 1) &amp; (df['c'].values == 7)] # 247 us
  </code></pre>
  
  <p>I suspect there are some overheads somewhere. My program has ~1k tuples, so it takes 511 * 1000 = 0.5s for one run. How can I improve further?</p>
  
  <h3>update:</h3>
  
  <p>hmm, I forgot to mention that the number of tuples are less than the total Cartesian product of distinct values in <code>'a', 'b','c'</code> in df. Wouldn't <code>groupby</code> do excess amount of work on indices that doesn't exist in my tuples?</p>