0

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?

Rotunjere
  • 69
  • 4
  • Does this answer your question? [Convert Pandas Column to DateTime](https://stackoverflow.com/questions/26763344/convert-pandas-column-to-datetime) – busybear Feb 17 '20 at 03:07
  • duplicated? https://stackoverflow.com/questions/466345/converting-string-into-datetime – Hunter Tran Feb 17 '20 at 03:07
  • Does this answer your question? [Converting string into datetime](https://stackoverflow.com/questions/466345/converting-string-into-datetime) – Grismar Feb 17 '20 at 03:27
  • What’s the problem? Have you tried anything, done any research? Stack Overflow is not a free code writing service. See: [tour], [ask], [help/on-topic], https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users. – AMC Feb 17 '20 at 04:02
  • Does this answer your question? [How to convert string to datetime format in pandas python?](https://stackoverflow.com/questions/32204631/how-to-convert-string-to-datetime-format-in-pandas-python) – AMC Feb 17 '20 at 04:02

2 Answers2

1

The following code will convert your String column to datetime64

df['Date'] = pd.to_datetime(df['Date'], infer_datetime_format=True)
Kavish
  • 69
  • 6
0

Could you try with below code

from datetime import datetime
datetime_object =datetime.strptime('01Jan2019', '%d%b%Y')
puhuk
  • 464
  • 5
  • 15