Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    $\begingroup$ The second snippet worked perfectly, Didn't know that I could round-off a datetime object. Thanks! $\endgroup$ Commented Nov 11, 2019 at 8:35
  • 1
    $\begingroup$ Is there a way to do this automatically for all columns using datetimes (without specifying them one by one), when doing read_excel()? $\endgroup$ Commented Mar 8, 2021 at 16:25
  • $\begingroup$ I don't know why, but when reading an xlsx file with pandas, some datetimes were off by a minute. So I had to use df.set_index(df.index.round(freq='h'), inplace=True), which seems really weird. I'd rather parse a CSV file and specify an explicit strftime format. $\endgroup$ Commented Jun 6, 2024 at 12:03