如何将对象类型转换为datetime64?

2024-05-23 09:41:39 发布

您现在位置:Python中文网/ 问答频道 /正文

当我看到数据类型时,它似乎是object,但我无法将其转换为datetime64

0    2017-11-29 17:14:00
1    2017-02-15 15:35:00
2    2018-10-18 08:02:00
3    2017-06-22 09:25:00
4    2017-09-21 11:12:00
Name: Data e Hora Indução Anestesica, dtype: object

我已经试过了,但不起作用

df['Data e Hora Indução Anestesica'].astype(str).astype(int)
hg = df['Data e Hora Indução Anestesica'].astype(str).str.zfill(6)
df['Data e Hora Indução Anestesica'] = pd.to_datetime(hg, format='%Y/%m/%d%H%M%S')

Tags: namedfdataobjecthgint数据类型dtype

热门问题