title: Which is the fastest way to extract day, month and year from a given date?
body: <p>I read a csv file containing 150,000 lines into a pandas dataframe. This dataframe has a field, <code>Date</code>, with the dates in <code>yyyy-mm-dd</code> format. I want to extract the month, day and year from it and copy into the dataframes' columns, <code>Month</code>, <code>Day</code> and <code>Year</code> respectively. For a few hundred records the below two methods work ok, but for 150,000 records both take a ridiculously long time to execute. Is there a faster way to do this for 100,000+ records?</p>
  
  <p>First method: </p>
  
  <pre><code>df = pandas.read_csv(filename)
  for i in xrange(len(df)): 
     df.loc[i,'Day'] = int(df.loc[i,'Date'].split('-')[2])
  </code></pre>
  
  <p>Second method: </p>
  
  <pre><code>df = pandas.read_csv(filename)
  for i in xrange(len(df)):
     df.loc[i,'Day'] = datetime.strptime(df.loc[i,'Date'], '%Y-%m-%d').day
  </code></pre>
  
  <p>Thank you.</p>