Search code examples
pandasdataframetypeskeyerror

I can't convert the Pandas Dataframe type to datetime


I am pretty sure I should do like:

df['date'] = pd.to_datetime(df['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

Solution

  • I have found the problem. The problem arises when you save the .csv in CSV UTF-8.