Other solutions did not work for me, so I applied a workaround using replace instead of combine :
def combine_date_time(df, datecol, timecol): return df.apply(lambda row: row[datecol].replace( hour=row[timecol].hour, minute=row[timecol].minute), axis=1 )
In your case:
combine_date_time(df, 'MEETING DATE', 'MEETING TIME')
It feels slow (I did not schedule it) , but it works .
UPDATE . I calculated both approaches for a relatively large dataset (> 500,000 rows) and both have the same runtime, but using combine is faster (59s for replace vs 50 seconds for combine ). Also see jezrael on this.
UPDATE2 . I tried jezrael approach:
def combine_date_time(df, datecol, timecol): return pd.to_datetime(df[datecol].dt.date.astype(str) + ' ' + df[timecol].astype(str))
This approach quickly sparkles in comparison, jezrael is right. I could not measure it, but it is obvious.
source share