title: Assign pandas dataframe column dtypes
body: <p>I want to set the <code>dtype</code>s of multiple columns in <code>pd.Dataframe</code> (I have a file that I've had to manually parse into a list of lists, as the file was not amenable for <code>pd.read_csv</code>)</p>
  
  <pre><code>import pandas as pd
  print pd.DataFrame([['a','1'],['b','2']],
                     dtype={'x':'object','y':'int'},
                     columns=['x','y'])
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>ValueError: entry not a 2- or 3- tuple
  </code></pre>
  
  <p>The only way I can set them is by looping through each column variable and recasting with <code>astype</code>. </p>
  
  <pre><code>dtypes = {'x':'object','y':'int'}
  mydata = pd.DataFrame([['a','1'],['b','2']],
                        columns=['x','y'])
  for c in mydata.columns:
      mydata[c] = mydata[c].astype(dtypes[c])
  print mydata['y'].dtype   #=&gt; int64
  </code></pre>
  
  <p>Is there a better way?</p>