change multiple columns in pandas dataframe to datetime

后端 未结 5 2014
无人及你
无人及你 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:57

    You can use apply to iterate through each column using pd.to_datetime

    data.iloc[:, 7:12] = data.iloc[:, 7:12].apply(pd.to_datetime, errors='coerce')
    

提交回复
热议问题