title: How to convert string to datetime with nulls - python, pandas?
body: <p>I have a series with some datetimes (as strings) and some nulls as 'nan':</p>
  
  <pre><code>import pandas as pd, numpy as np, datetime as dt
  df = pd.DataFrame({'Date':['2014-10-20 10:44:31', '2014-10-23 09:33:46', 'nan', '2014-10-01 09:38:45']})
  </code></pre>
  
  <p>I'm trying to convert these to datetime:</p>
  
  <pre><code>df['Date'] = df['Date'].apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%d %H:%M:%S'))
  </code></pre>
  
  <p>but I get the error:</p>
  
  <pre><code>time data 'nan' does not match format '%Y-%m-%d %H:%M:%S'
  </code></pre>
  
  <p>So I try to turn these into actual nulls:</p>
  
  <pre><code>df.ix[df['Date'] == 'nan', 'Date'] = np.NaN
  </code></pre>
  
  <p>and repeat:</p>
  
  <pre><code>df['Date'] = df['Date'].apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%d %H:%M:%S'))
  </code></pre>
  
  <p>but then I get the error:</p>
  
  <blockquote>
    <p>must be string, not float</p>
  </blockquote>
  
  <p>What is the quickest way to solve this problem?</p>