如何更改源包含多种格式的日期格式
如何在 python 中将格式日期从 12-Mar-2022 更改为 , format='%d/%m/%Y'
所以问题是我从谷歌表中读取数据,其中数据包含多种格式,其中一些是12/03/2022,其中一些是 2022 年 3 月 12 日。
我尝试使用此方法时出现了错误,因为与 2022 年 3 月 12 日不匹配 defectData_x['date'] = pd.to_datetime(defectData_x['date'], format='%d/%m/%Y')
感谢您的帮助
How to change format date from 12-Mar-2022 to , format='%d/%m/%Y' in python
so the problem is I read data from the google sheet where in the data contain multiple format, some of them is 12/03/2022 and some of them 12-Mar-2022.
I tried using this got error of couse because doesn't match for 12-Mar-2022
defectData_x['date'] = pd.to_datetime(defectData_x['date'], format='%d/%m/%Y')
Appreciate your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要忘记date1的数据类型不是日期时间而是对象
,因此最好在最终结果之后使用date列和date1
列,您可以删除日期列
添加我的示例:
don forget date1's dtype is not datetime but object
so it is better using date column and date1 column both before make final result
after final result, you can drop date column
add my example: