将一种格式转换为日期时间格式

时间:2016-04-19 09:21:38

标签: python python-2.7 pandas

这是我的DataFrame

issue,received_time
aa,25-06-15 08:42:43.830000000 PM
bb,25-06-15 08:42:43.830000000 PM

我需要输出:

issue,received_time
aa,25-06-15
bb,25-06-15

1 个答案:

答案 0 :(得分:1)

我认为您可以使用dt.date

df['received_time'] = df['received_time'].dt.date
print df
  issue received_time
0    aa    2015-06-25
1    bb    2015-06-25

如果列类型不是datetime,请先按to_datetime转换:

df['received_time'] = pd.to_datetime(df['received_time']).dt.date
print df
  issue received_time
0    aa    2015-06-25
1    bb    2015-06-25