pandas date to string
<p>i have a datetime <code>pandas.Series</code>. One column called "dates". I want to get 'i' element in loop like string.</p>

<p><code>s.apply(lambda x: x.strftime('%Y.%m.%d'))</code> or
<code>astype(str).tail(1).reset_index()['date']</code> or many other solutions don't work.</p>

<p>I just want a string like <code>'2016-09-16'</code> (first datetime element in series) and not what is currently returned, which is:</p>

<pre><code> ss = series_of_dates.astype(str).tail(1).reset_index()['date']
"lol = %s" % ss 
</code></pre>

<blockquote>
  <p><code>lol = 0    2016-09-16\nName: date, dtype: object</code></p>
</blockquote>

<p>I need just:</p>

<blockquote>
  <p><code>lol = 2016-09-16</code></p>
</blockquote>

<p>because I need </p>

<blockquote>
  <p><strong><code>some string</code></strong> % a , b , s ,d</p>
</blockquote>

<p>.....  without even '/n' in a, b ,s ...</p>

<p>In order to extract the value, you can try:</p>

<pre><code>ss = series_of_dates.astype(str).tail(1).reset_index().loc[0, 'date']
</code></pre>

<p>using <code>loc</code> will give you the contents just fine.</p>

python datetime pandas time-series