I have a fixed-length Time list:
time_list = ['21:00:00', '22:00:00', '23:00:00', '00:00:00', '01:00:00']
However, I have a long Date list:
date_list =
['2019-07-09',
'2019-07-09',
'2019-07-09',
'2019-07-09',
'2019-07-09',
'2019-07-09',
'2019-07-09',
'2019-07-10',
'2019-07-10',
'2019-07-10',
'2019-07-10',
'2019-07-08',
'2019-07-08',
'2019-07-08'
....
]
What I want to do is join date_list and time_list so the new df looks like this:
date_time =
['2019-07-09 21:00:00',
'2019-07-09 22:00:00',
'2019-07-09 23:00:00',
'2019-07-09 00:00:00',
'2019-07-09 01:00:00',
'2019-07-09 21:00:00',
'2019-07-09 22:00:00',
'2019-07-10 23:00:00',
'2019-07-10 00:00:00',
'2019-07-10 01:00:00',
'2019-07-10 21:00:00',
'2019-07-08 22:00:00',
'2019-07-08 23:00:00',
'2019-07-08 00:00:00'
....
]
As you can see that the time_list is applied to date_list similar to one to one mapping. When the time_list runs out of value, it is repeated again but date_list is the same length and won't repeat.
What did I do?
I tried to do:
pd.MultiIndex.from_product([date_list, time_list]).map(' '.join).tolist()
But it does for each date_list joins time_list which gives extra values.
I also tried to do this but wont work:
[date_list + " " + time_list]
Can you please help?