gps nt_date
4002 20-Dec-16
4002 20-Dec-16
C-4 30-Jan-17
Y21-21 17-Nov-16
49a 22-Dec-16 在上面的数据框中,如何将nt_date列转换为pandas datetime?我正在使用这个,但它不起作用:
pd.to_datetime(df['nt_date'], format='%d-%m-%Y')如何解决这个问题?
发布于 2018-10-17 10:22:58
您使用的指令稍有错误。尝试使用%b (Month作为区域设置的缩写名称)和%y (2位年份,而不是4位数字的%Y ):
df['nt_date'] = pd.to_datetime(df['nt_date'], format='%d-%b-%y')
>>> df
gps nt_date
0 4002 2016-12-20
1 4002 2016-12-20
2 C-4 2017-01-30
3 Y21-21 2016-11-17
4 49a 2016-12-22有关更多信息,请访问these docs
https://stackoverflow.com/questions/52846411
复制相似问题