Pandas merge a "%Y%M%D" date column with a "%H:%M:%S" time column I have a dataframe with a column composed by date object and a column composed by time object.
I have to merge the two columns.
Personally, I think it is so ugly the following solution.
Why I have to cast to str?
I crafted my solution based on this answer
#importing all the necessary libraries 
import pandas as pd 
import datetime

#I have only to create a Minimal Reproducible Example
time1 = datetime.time(3,45,12)
time2 = datetime.time(3,49,12)
date1 = datetime.datetime(2020, 5, 17)
date2 = datetime.datetime(2021, 5, 17)
date_dict= {&quot;time1&quot;:[time1,time2],&quot;date1&quot;:[date1,date2]}

df=pd.DataFrame(date_dict)

df[&quot;TimeMerge&quot;] = pd.to_datetime(df.date1.astype(str)+' '+df.time1.astype(str))
We can let pandas handle this for us and use DataFrame.apply and datetime.datetime.combine like this:
df[&quot;TimeMerge&quot;] = df.apply(lambda row: datetime.datetime.combine(row.date1, row.time1), axis=1)


Although the following approach is more explicit and might therefore be more readable if you're not familiar with DataFrame.apply, I would strongly recommend the first approach.
You could also manually map datetime.datetime.combine over a zip object of date1 and time1:
def combine_date_time(d_t: tuple) -&gt; datetime.datetime:
    return datetime.datetime.combine(*d_t)

df[&quot;TimeMerge&quot;] = pd.Series(map(combine_date_time, zip(df.date1, df.time1)))

You can also inline it as an anonymous lambda function:
df[&quot;TimeMerge&quot;] = pd.Series(map(lambda d_t: datetime.datetime.combine(*d_t), zip(df.date1, df.time1)))

This is handy for simple operations, but I would advise against this one-liner in this case.

By the way, the answer your were looking for can also be found under the question you linked.