7

Given a dataframe with time series that looks like this:

                      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

How can I get rid of the 'seconds' of the index so it looks like this:

                   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

Thanks

hernanavella
  • 5,462
  • 8
  • 47
  • 84

1 Answers1

9

you can use map and strftime like this:

df.index =df.index.map(lambda t: t.strftime('%Y-%m-%d %H:%M'))
JAB
  • 12,401
  • 6
  • 45
  • 50