Datetime milliseconds to seconds in Pandas

前端 未结 2 664
栀梦
栀梦 2020-12-21 07:56

Have a datetime column in pandas dataframe with values like these:

time
2018-04-11 22:18:30.122
2018-04-11 23:00:21.399

I\'m wondering how

2条回答
  •  生来不讨喜
    2020-12-21 08:29

    well, ceil is also work for this question.

    df['time'] = pd.to_datetime(df['time'])
    df['time'] = df['time'].dt.ceil('T')
    df
                     time
    0 2018-04-11 22:19:00
    1 2018-04-11 23:01:00
    

提交回复
热议问题