Convert mmm-yy to datetime in dataframe column

Viewed 13

I have a dataframe containing a column having values like feb-20.

How to convert it to datetime

1 Answers

This will treat the day as 1:

pd.to_datetime(df["col_name"], format="%b-%y")

Because you use 2-digit year, there are some oddities around the conversion: anything up to 68 means 20.. while 69+ means 19...

Related