title: Fastest way to convert dtypes for big datasets in Python?
body: <p>So, I'm working with a relatively big dataset and I feel like it's taking to much time to convert the columns into their proper dtypes.</p>
  
  <p>So far, I'm using <code>apply</code> with <code>to_datetime</code> and <code>to_numeric</code> like so:</p>
  
  <pre><code>df.iloc[:,[0,1,9]] = df.iloc[:,[0,1,9]].apply(pd.to_datetime, 
  errors='coerce')
  df.iloc[:,2:8] = df.iloc[:,2:8].apply(pd.to_numeric, errors='coerce')
  </code></pre>
  
  <p>I was able to convert the columns, but it took ~20 minutes. There must be a quicker way?</p>
  
  <p>If not, are my only choices to cut down the dataset for data exploration or get a faster computer?</p>
  
  <p>EDIT: The problem was mainly due to using to_datetime without formatting the date and time. There was also improvement in performance when I removed iloc and apply, though it is not as significant as formatting the date and time.</p>
  
  <p>Here's the time each scenario took:</p>
  
  <ul>
  <li>No formatting using iloc took 1027.11 s to run</li>
  <li>No formatting without using iloc took 789.15 s to run</li>
  <li>datetime with formatting took 19.47 s to run</li>
  </ul>
  
  <p>Huge improvement. This was on a dataset with 2,049,280 rows. Thanks @ScottBoston and @DiegoAgher!</p>