我无法将 Pandas Dataframe 类型转换为日期时间
问题描述:
我很确定我应该这样做:
I am pretty sure I should do like:
df['date'] = pd.to_datetime(df['date'])
但不断收到错误:KeyError:'date'"数据框如下所示:
But is keep getting the ERROR: "KeyError: 'date'" The data frame looks like this:
date value
0 2004-01-01 0.265
1 2004-01-02 0.440
2 2004-01-05 -0.955
3 2004-01-06 -1.892
答
我发现了问题.将 .csv 保存为 CSV UTF-8 时会出现问题.
I have found the problem. The problem arises when you save the .csv in CSV UTF-8.