AttributeError: Can only use .dt accessor with datetimelike values

datetime
python

#1

donar_train['project_submitted_datetime'] = pd.to_datetime(donar_train['project_submitted_datetime'])

while im trying to convert the “project_submitted_datetime” column( the column values format is “2016-11-18 14:45:59”) to datatime format , i’m getting the error

Can only use .dt accessor with datetimelike values


#2

Hi @vishnuvarakala,

You have not specified the format. Try using the below code line:

donar_train['project_submitted_datetime'] = pd.to_datetime(donar_train.project_submitted_datetime, format='%d-%m-%Y %H:%M')

You can also refer this course. The python codes are available in the course as well.


#3

Thankyou :slight_smile: