Skip to content Skip to sidebar Skip to footer

Attributeerror: 'str' Object Has No Attribute 'to_datetime'

I have a code that reads an excel data sheet (a table) into a DataFrame and convert a 'date' column (with values e.g. 20150508) into date time, df['date'] = df['date'].astype(str)

Solution 1:

There is no to_datetime method for Series only for Index objects it's the top-level method you want:

dates = pd.to_datetime(df['date'])

Post a Comment for "Attributeerror: 'str' Object Has No Attribute 'to_datetime'"