Rotunjere
Rotunjere

Reputation: 69

How can I convert string to datetime?

How can I convert string column to datetime in pandas?

My columns is as follows

Date

01Jan2019
01Feb2019
01Mar2019

How can I convert this to a pandas date time?

Upvotes: 0

Views: 69

Answers (2)

kavish-p
kavish-p

Reputation: 82

The following code will convert your String column to datetime64

df['Date'] = pd.to_datetime(df['Date'], infer_datetime_format=True)

Upvotes: 1

puhuk
puhuk

Reputation: 484

Could you try with below code

from datetime import datetime
datetime_object =datetime.strptime('01Jan2019', '%d%b%Y')

Upvotes: 0

Related Questions