如何删除Pandas数据帧索引的'秒'?

her*_*lla 6 python time-series dataframe pandas

给定具有时间序列的数据框,如下所示:

                      Close
2015-02-20 14:00:00  1200.1
2015-02-20 14:10:00  1199.8
2015-02-21 14:00:00  1199.3
2015-02-21 14:10:00  1199.0
2015-02-22 14:00:00  1198.4
2015-02-22 14:10:00  1199.7
Run Code Online (Sandbox Code Playgroud)

我怎样才能摆脱索引的'秒',看起来像这样:

                   Close
2015-02-20 14:00  1200.1
2015-02-20 14:10  1199.8
2015-02-21 14:00  1199.3
2015-02-21 14:10  1199.0
2015-02-22 14:00  1198.4
2015-02-22 14:10  1199.7
Run Code Online (Sandbox Code Playgroud)

谢谢

JAB*_*JAB 9

你可以使用mapstrftime喜欢这样:

df.index =df.index.map(lambda t: t.strftime('%Y-%m-%d %H:%M'))
Run Code Online (Sandbox Code Playgroud)