I have a task where I need to generate 10-min interval between the given time range. For example,
start_time = '2020-09-02 17:33:04.472', end_time = '2020-09-02 20:19:14.859'
Desired Output:
start_times_list = ['2020-09-02 17:30:00', '2020-09-02 17:40:00', '2020-09-02 17:50:00', '2020-09-02 18:00:00', '2020-09-02 18:10:00', '2020-09-02 18:20:00', '2020-09-02 18:30:00', '2020-09-02 18:40:00','2020-09-02 18:50:00', '2020-09-02 19:00:00', '2020-09-02 19:10:00', '2020-09-02 19:20:00', '2020-09-02 19:30:00', '2020-09-02 19:40:00', '2020-09-02 19:50:00', '2020-09-02 20:00:00', '2020-09-02 20:10:00', '2020-09-02 20:20:00']
end_times_list = ['2020-09-02 17:40:00', '2020-09-02 17:50:00', '2020-09-02 18:00:00', '2020-09-02 18:10:00', '2020-09-02 18:20:00', '2020-09-02 18:30:00', '2020-09-02 18:40:00','2020-09-02 18:50:00', '2020-09-02 19:00:00', '2020-09-02 19:10:00', '2020-09-02 19:20:00', '2020-09-02 19:30:00', '2020-09-02 19:40:00', '2020-09-02 19:50:00', '2020-09-02 20:00:00', '2020-09-02 20:10:00', '2020-09-02 20:20:00', '2020-09-02 20:30:00']
I have tried the below method which creates only a date range from start datetime, but not from the floor(min)
import pandas as pd
l = (pd.DataFrame(columns=['NULL'],
index=pd.date_range('2020-09-02 17:33:04', '2020-09-02 20:19:14',
freq='10T'))
.between_time('07:00','22:00')
.index.strftime('%Y-%m-%d %H:%M:%S')
.tolist()
)
l
Current Output
['2020-09-02 17:33:04',
'2020-09-02 17:43:04',
'2020-09-02 17:53:04',
'2020-09-02 18:03:04',
'2020-09-02 18:13:04',
'2020-09-02 18:23:04',
'2020-09-02 18:33:04',
'2020-09-02 18:43:04',
'2020-09-02 18:53:04',
'2020-09-02 19:03:04',
'2020-09-02 19:13:04',
'2020-09-02 19:23:04',
'2020-09-02 19:33:04',
'2020-09-02 19:43:04',
'2020-09-02 19:53:04',
'2020-09-02 20:03:04',
'2020-09-02 20:13:04']