How do I convert dates in a Pandas data frame to a 'date' data type?

前端 未结 10 2282
独厮守ぢ
独厮守ぢ 2020-11-28 02:56

I have a Pandas data frame, one of the column contains date strings in the format YYYY-MM-DD

For e.g. \'2013-10-28\'

At the moment th

10条回答
  •  佛祖请我去吃肉
    2020-11-28 03:45

    Another way to do this and this works well if you have multiple columns to convert to datetime.

    cols = ['date1','date2']
    df[cols] = df[cols].apply(pd.to_datetime)
    

提交回复
热议问题