Convert Pandas Column to DateTime

前端 未结 5 2098
情话喂你
情话喂你 2020-11-21 11:38

I have one field in a pandas DataFrame that was imported as string format. It should be a datetime variable. How do I convert it to a datetime column and then filter based

5条回答
  •  春和景丽
    2020-11-21 11:48

    If you have more than one column to be converted you can do the following:

    df[["col1", "col2", "col3"]] = df[["col1", "col2", "col3"]].apply(pd.to_datetime)
    

提交回复
热议问题