def closest(row):
    matches = df2.loc[(df2.employee_id == row.employee_id) & (df2.
        session_id == row.session_id)]
deltas = matches.date_start_time - row.date_start_time
deltas = deltas.loc[deltas <= timedelta(minutes=threshold)]
try:
    return matches.loc[deltas.idxmin()]
except ValueError:
    return row
df1 = df1.apply(closest, axis=1)
cols = ['date_start_time', 'employee_id', 'session_id']
print(df1.merge(df2, on=cols, how='outer')[cols])
pandas merging based on a timestamp which do not match exactly