I have create a simple single column dataframe with string time values in %H:%M:%S format.
import pandas as pd
data = ['22:00:00', '22:30:00', '23:00:00', '23:30:00', '00:00:00', '00:30:00', '01:00:00']
df = pd.DataFrame(data, columns = ['DateTime'])
df
The result is:
DateTime
0 22:00:00
1 22:30:00
2 23:00:00
3 23:30:00
4 00:00:00
5 00:30:00
6 01:00:00
How do I attach a date, i.e. today: 2019-10-28 to the time in the first row and have it extend to all the remaining times, wrapping over a new day at midnight (like in column 4).
Desired result is:
DateTime
0 2019-10-28 22:00:00
1 2019-10-28 22:30:00
2 2019-10-28 23:00:00
3 2019-10-28 23:30:00
4 2019-10-29 00:00:00
5 2019-10-29 00:30:00
6 2019-10-29 01:00:00
I have attempted
df['DateTime'] = pd.to_datetime(df.DateTime, format='%H:%M:%S')
but it starts the date at 1900-01-01 and does not wrap over at midnight.