How to change the datetime format in pandas

前端 未结 8 1903
萌比男神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条回答
  •  旧时难觅i
    2020-11-21 23:53

    You can try this it'll convert the date format to DD-MM-YYYY:

    df['DOB'] = pd.to_datetime(df['DOB'], dayfirst = True)
    

提交回复
热议问题