我想重新格式化数据集中的时间戳,使其成为日期+时间
这是我的数据集
我试过这个
data1 = pd.read_excel(r"C:\Users\user\Desktop\Consumption.xlsx")
data1['Timestamp']= pd.to_datetime(['Timestamp'], unit='s')
我犯了这个错误
ValueError: non convertible value Timestamp with the unit 's'
我还试图不在pd.to_datetime函数中传递“unit”,但它给出了一个错误 时间戳的类型是对象。请帮忙
试试这个:
我建议您检查函数here的文档
如果要添加日期时间,可以采用以下格式:
format='%d/%m/%Y %H:%M:%S'
datetimes的格式不是unix时间,因此引发错误。您可以按
;
分割值,按str[1]
选择第二个列表,然后转换为日期时间:相关问题 更多 >
编程相关推荐