pandas: extract date and time from timestamp

前端 未结 2 701
名媛妹妹
名媛妹妹 2020-12-24 08:20

I have a timestamp column where the timestamp is in the following format

2016-06-16T21:35:17.098+01:00

I want to extract date

2条回答
  •  误落风尘
    2020-12-24 08:56

    Do this first:

    df['time'] = pd.to_datetime(df['timestamp'])
    

    Before you do your extraction as usual:

    df['dates'] = df['time'].dt.date
    

提交回复
热议问题