title: Setting column types while reading csv with pandas
body: <p>Trying to read <strong>csv</strong> file into <strong><em>pandas</em></strong> dataframe with the following formatting</p>
  
  <pre><code>dp = pd.read_csv('products.csv', header = 0,  dtype = {'name': str,'review': str,
                                                        'rating': int,'word_count': dict}, engine = 'c')
  print dp.shape
  for col in dp.columns:
      print 'column', col,':', type(col[0])
  print type(dp['rating'][0])
  dp.head(3)
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>(183531, 4)
  column name : &lt;type 'str'&gt;
  column review : &lt;type 'str'&gt;
  column rating : &lt;type 'str'&gt;
  column word_count : &lt;type 'str'&gt;
  &lt;type 'numpy.int64'&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/764Kv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/764Kv.png" alt="enter image description here"></a></p>
  
  <p>I can sort of understand that <strong><em>pandas</em></strong> might be finding it difficult to convert a string representation of a dictionary into a dictionary given <a href="https://stackoverflow.com/questions/988228/converting-a-string-to-dictionary">this</a> and <a href="https://stackoverflow.com/questions/13675942/converting-string-to-dict?lq=1">this</a>. But how can the content of the "rating" column be both str and numpy.int64???</p>
  
  <p>By the way, tweaks like not specifying an engine or header do not change anything.</p>
  
  <p>Thanks and regards</p>