title: Extract year from YYYYMMDD column in Pandas DataFrame
body: <p>I have a pandas DataFrame in which I would like to create an additional column containing only the year which I extract from a column in YYYYMMDD format.
  When searching the forum I found the <code>to_datetime</code> command, but for my case it didn't work.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>df = pd.DataFrame({'name' : ['A','B'],
                     'date' :[20130102,20140511]})
  
  df['date'] = pd.to_datetime(df['date'])
  df['year'] = df['date'].dt.year
  </code></pre>
  
  <p>what I get as output is:</p>
  
  <pre><code>                           date name   year
  0 1970-01-01 00:00:00.020130102    A   1970
  1 1970-01-01 00:00:00.020140511    B   1970
  </code></pre>
  
  <p>but I would like to get:</p>
  
  <pre><code>       date name  year
  0  20130102    A  2013
  1  20140511    B  2014
  </code></pre>
  
  <p>I also tried it without <code>to_datetime</code> as my date is not in exactly in the yyyy-mm-dd format, but also couldn't make it that way.
  I hope you can help me with this 'newbie' problem, thanks a lot!</p>