title: Python - convert date string from YYYY-MM-DD to DD-MMM-YYYY using datetime?
body: <p>So I have read a number of threads on this, and am still stumped. Any help would be sincerely appreciated.</p>
  
  <p>I have a column in a dataframe that contains strings of dates, or nothing.  Strings are in this format: <code>2017-10-17</code>, i.e. <code>YYYY-MM-DD</code>.</p>
  
  <p>I want to convert these to <code>DD-MMM-YYYY</code>, so the above would read <code>17-Oct-2017</code>.</p>
  
  <p>Here is the code that I have, which seems to do nothing.  It doesn't error out, but it doesn't actually modify the dates; they are the same as before. I'm calling this in the beginning: <code>import datetime</code></p>
  
  <pre><code>df_combined['VisitDate'].apply(lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').strftime('%d-%b-%Y') if x != "" else "")
  </code></pre>
  
  <p>I expected this to return a string in a different format than the format the original string was in when it's read from the column.</p>