I am trying to combine the date to multiple time columns in my dataframe. I am able to iterate through each row, but I am confused as to how I combine the columns. For example:
date first_time second_time ....
0 2008/09/11 12:32 17:56
1 2016/12/02 06:43 14:02
2 2001/01/01 02:45 20:13
.
.
.
With .iterrows() I am able to break it down to each row. So row['date'] would be the date for that particular column. However, I need to use datetime to combine the date with each of the columns. I keep on getting errors for various methods I'm finding online. If I have row['date'] and row['first_time'], how could I combine them in the dataframe (also with date and every other time column)?
The end result should be this:
first_datetime second_datetime ....
0 2008/09/11 12:32 2008/09/11 17:56
1 2016/12/02 06:43 2016/12/02 14:02
2 2001/01/01 02:45 2001/01/01 20:13
.
.
.
You can first
set_index
with columndate
and then in loop oftime
columns convertto_datetime
:For more dynamic solution convert only columns with
time
in name: