My dataframe has a DOB
column (example format 1/1/2016
) which by default gets converted to pandas dtype \'object\': DOB object
Below is the code worked for me, And we need to be very careful for format. Below link will be definitely useful for knowing your exiting format and changing into desired format(Follow strftime() and strptime() Format Codes on below link):
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
data['date_new_format'] = pd.to_datetime(data['date_to_be_changed'] , format='%b-%y')