擅长:python、mysql、java
<p>首先将<code>q_date</code>列转换为<code>datetime64[ns]</code>系列,然后使用自定义格式字符串<code>map</code>覆盖该列</p>
<pre><code>In [178]: df = df.convert_objects(convert_dates='coerce')
In [179]: df
Out[179]:
q_string q_visits q_date
0 red 1790 2012-02-10 00:00:00
1 blue 364 2012-02-10 00:00:00
2 current 280 2012-02-10 00:00:00
3 molecular 259 2012-02-10 00:00:00
4 cell 201 2012-02-10 00:00:00
In [180]: df['iso_q_date'] = df.q_date.map(lambda x: datetime.datetime.strftime(x, '%y%m%dT%H:%M%SZ'))
In [181]: df
Out[181]:
q_string q_visits q_date iso_q_date
0 red 1790 2012-02-10 00:00:00 120210T00:0000Z
1 blue 364 2012-02-10 00:00:00 120210T00:0000Z
2 current 280 2012-02-10 00:00:00 120210T00:0000Z
3 molecular 259 2012-02-10 00:00:00 120210T00:0000Z
4 cell 201 2012-02-10 00:00:00 120210T00:0000Z
</code></pre>