-1

Add a column (called TIME_HOURS) based on the data in the TIME column and rounded up the value to the nearest hour. For example, if the original TIME row said: ‘02/28/2018 05:40:00 PM’ we want ‘2018-02-28 18:00:00’
(the change is that 5:40pm was rounded up to 6:00pm and the TIME_HOUR column is actually a proper datetime and not a string).

  • 1
    Does this answer your question? [Round time to nearest hour python](https://stackoverflow.com/questions/48937900/round-time-to-nearest-hour-python) – Proko Feb 07 '21 at 22:08

1 Answers1

1

You can use pandas.Series.dt.round:

df["TIME_HOURS"].dt.round('H')
Pablo C
  • 4,661
  • 2
  • 8
  • 24