python pandas用几个月的名字解析日期时间字符串 [英] python pandas parse datetime string with months names

查看:80
本文介绍了python pandas用几个月的名字解析日期时间字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指出我要使用的格式或代码段来解析日期,例如

Can someone point me to a format or a code snippet to parse date in format like

04SEP12:00:00:00

那个%dd%mm%YY:%HH:%MM: %SS 不起作用。

推荐答案

使用格式字符串:' %d%b%y:%H:%M:%S'并将其作为 to_datetime ,您可以在文档

Use format string: '%d%b%y:%H:%M:%S' and pass this as the format for to_datetime, you can find the format options in the docs:

In [73]:

pd.to_datetime('04SEP12:00:00:00', format='%d%b%y:%H:%M:%S')
Out[73]:
Timestamp('2012-09-04 00:00:00')

这篇关于python pandas用几个月的名字解析日期时间字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆