I have a date column, which is formatted as object in the following format:
May 12, 2021
Apr 1, 2019
I would need to change the data type to date. I found a way, which carves out DD MMM YYYY into separated columns and then creates final date column afterwards. However this is obviously not the most elegant way. Could you advise me better solution, please?
data['month'] = data['release_date'].str.split(' ').str[0]
data['year'] = data['release_date'].str.split(', ').str[1]
data['day'] = data['release_date'].str.split(' ').str[1].replace(',', '')
data['date'] = pd.to_datetime(data[['year', 'month', 'day']])