I have a column of datatimes in the format: 2015-06-25 03:29:58 which I believe is in datetime64. I would like to round them to the nearest ten minutes.
i.e
2015-06-25 03:29:58 = 2015-06-25 03:30:00
2015-06-25 03:24:58 = 2015-06-25 03:20:00
2015-06-25 03:59:58 = 2015-06-25 04:00:00
I have looked all over for the answer for this problem, there are a few threads and solutions for rounding time, such as this one: How do I round datetime column to nearest quarter hour
However this method can only round down, not round up.
I have also seen other solutions, but cannot work out how to apply them to a datetime in a dataframe.
I have tried many different versions of:
from pandas import *
import datetime
rounded_ten = lambda dt: datetime.datetime(dt.year, dt.month, dt.day,(dt.hour), 10*(round(dt.minute/10)))
dataframe1['Device Time'] = dataframe1['Device Time'].apply(rounded_ten)
However this does not work because when you round 55 upwards it gives the answer of 60. Which is not acceptable within this format. I wanted to apply some if statements, however I could not understand how to apply them to this format.
Any help would be greatly appreciated.