标签: python python-datetime
我有HH:MM:SS对象类型的单独列。我想将对象类型转换为DateTime格式。遇到以下错误。
数据集时间列[“ ACCIDENT_TIME]:
答案 0 :(得分:1)
您也可以尝试以下方法:
import pandas as pd df['col_name'] = pd.to_datetime(df['col_name'], errors='coerce')
答案 1 :(得分:0)
如果要更改列的dtype,可以按以下方式操作:
df ['col_name'] = df ['col_name']。astype('datetime64 [ns]')