title: Pandas DataFrame performance
body: <p>Pandas is really great, but I am really surprised by how inefficient it is to retrieve values from a Pandas.DataFrame.  In the following toy example, even the DataFrame.iloc method is more than 100 times slower than a dictionary.  </p>
  
  <p>The question: Is the lesson here just that dictionaries are the better way to look up values?  Yes, I get that that is precisely what they were made for.  But I just wonder if there is something I am missing about DataFrame lookup performance.</p>
  
  <p>I realize this question is more "musing" than "asking" but I will accept an answer that provides insight or perspective on this.  Thanks.</p>
  
  <pre><code>import timeit
  
  setup = '''
  import numpy, pandas
  df = pandas.DataFrame(numpy.zeros(shape=[10, 10]))
  dictionary = df.to_dict()
  '''
  
  f = ['value = dictionary[5][5]', 'value = df.loc[5, 5]', 'value = df.iloc[5, 5]']
  
  for func in f:
      print func
      print min(timeit.Timer(func, setup).repeat(3, 100000))
  </code></pre>
  
  <blockquote>
    <p>value = dictionary[5][5]</p>
    
    <p>0.130625009537</p>
    
    <p>value = df.loc[5, 5]</p>
    
    <p>19.4681699276</p>
    
    <p>value = df.iloc[5, 5]</p>
    
    <p>17.2575249672</p>
  </blockquote>