更改数据帧索引的秒数

问题描述 投票:2回答:1

我得到了一个熊猫数据框,其中的索引是一个时间戳,如

"2020-03-14 05:02:06+04:00" or "2020-03-14 08:34:27+04:00"

我希望所有秒数都为00,即:

"2020-03-14 05:02:06+04:00"  -->  "2020-03-14 05:02:00+04:00" 

"2020-03-14 08:34:27+04:00"  -->  "2020-03-14 08:34:00+04:00"

是否有不参与构建新列的简便方法?

python-3.x pandas
1个回答
1
投票

按分钟使用DatetimeIndex.floor

DatetimeIndex.floor
© www.soinside.com 2019 - 2024. All rights reserved.