2024-09-28 17:02:29 发布
网友
我试图在python中转换dataframe中列的datetime格式 原始日期-2018年7月16日00:00 最终日期-2018-08-16 00:00
results['Date1']=dt.datetime.strptime(str(results['Date']), "%d-%b-%Y %H:%M").strftime("%Y-%m-%d %H:%M")
但它给了我价值观上的错误。在syntex中尝试特定字符串时,它是有效的
这应该起作用:
result['Date1'] = pd.to_datetime(result['Date1'], format="%d-%b-%Y %H:%M").dt.strftime('%Y-%m-%d %H:%M')
输入:
Date1 0 16-Jul-2018 00:00
输出:
Date1 0 2018-07-16 00:00
这应该起作用:
输入:
输出:
相关问题 更多 >
编程相关推荐