I have a dataframe like as shown below
df = pd.DataFrame({'login_datetime':['5/7/2013 09:27:00 AM','09/08/2013 11:21:00 AM','06/06/2014 08:00:00 AM','06/06/2014 05:00:00 AM','12/11/2011 10:00:00 AM'],
'logout_datetime':['15/7/2013 09:27:00 AM','09/08/2013','06/06/2014 08:00:00','06/06/2014','12/11/2011']})
df.login_datetime = pd.to_datetime(df.login_datetime)
df.logout_datetime = pd.to_datetime(df.logout_datetime)
I would like to replace the timestamp 00:00:00 in logout_datetime records with corresponding login_datetime timestamp when the dates are matching. Please note that 00:00:00 is not always displayed in jupyter notebook
For ex: for 2nd record the dates are matching but logout timestamp is 00:00:00 AM, So, I would like to change it to 11:21:00 AM
I tried the below but not sure how to strip the timestamp and paste it to other column (I don't wish to copy whole column)
df['ts'] = [datetime.datetime.time(d) for d in df['login_datetime']]
df['new_logout_time'] = df['logout_datetime'] + df['ts']
I expect my output to be like as shown below
login_datetime logout_datetime
2013-05-07 09:27:00 2013-07-15 09:27:00
2013-09-08 11:21:00 2013-09-08 11:21:00
2014-06-06 08:00:00 2014-06-06 08:00:00
2014-06-06 05:00:00 2014-06-06 05:00:00
2011-12-11 10:00:00 2011-12-11 10:00:00