How to change the datetime format in pandas

前端 未结 8 1897
萌比男神i
萌比男神i 2020-11-21 23:26

My dataframe has a DOB column (example format 1/1/2016) which by default gets converted to pandas dtype \'object\': DOB object

8条回答
  •  别那么骄傲
    2020-11-21 23:42

    The below code worked for me instead of the previous one - try it out !

    df['DOB']=pd.to_datetime(df['DOB'].astype(str), format='%m/%d/%Y')
    

提交回复
热议问题