Using `apply` on datetime64 series in pandas
<p>I have a Series of <code>datetime64[ns]</code> objects. I would like to apply <code>strftime('%d-%m-%Y')</code> to all of them, for reversing the order of year,day,month. I tried using:</p>

<pre><code>series.apply(time.strftime('%d-%m-%Y'))
</code></pre>

<p>But I get the error:</p>

<blockquote>
  <p>TypeError: 'str' object is not callable</p>
</blockquote>

<p>Any idea on the right way to do this elegantly?</p>

<p>I think you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.dt.strftime.html" rel="nofollow"><code>Series.dt.strftime</code></a>:</p>

<pre><code>series.dt.strftime('%d-%m-%Y')
</code></pre>

<p>Or if is necessary convert <code>Series</code> <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow"><code>to_datetime</code></a> first:</p>

<pre><code>pd.to_datetime(series).dt.strftime('%d-%m-%Y')
</code></pre>

python python-3.x pandas numpy strftime