【发布时间】:2017-02-09 21:13:29
【问题描述】:
我有一个名为“df”的熊猫数据框,如下所示
value
2015-09-27 03:58:30 1.0
2015-09-27 03:59:30 1.0
2015-09-27 04:00:30 1.0
2015-09-27 04:01:30 1.0
我只想抽出几秒钟来得到这个
value
2015-09-27 03:58:00 1.0
2015-09-27 03:59:00 1.0
2015-09-27 04:00:00 1.0
2015-09-27 04:01:00 1.0
我该怎么做?
我试过了
df.index.to_series().apply(datetime.replace(second=0, microsecond=0))
但我总是出错
TypeError: descriptor 'replace' of 'datetime.datetime' object needs an argument
【问题讨论】:
标签: python pandas indexing seconds