change multiple columns in pandas dataframe to datetime

后端 未结 5 2025
无人及你
无人及你 2021-01-30 22:38

I have a dataframe of 13 columns and 55,000 rows I am trying to convert 5 of those rows to datetime, right now they are returning the type \'object\' and I need to transform thi

5条回答
  •  滥情空心
    2021-01-30 22:55

    my_df[['column1','column2']] =     
    my_df[['column1','column2']].apply(pd.to_datetime, format='%Y-%m-%d %H:%M:%S.%f')
    

    Note: of course the format can be changed as required.

提交回复
热议问题