dic = {'Employee ID':emp_id, 'Log Date':emp_logdate, 'Log Time':emp_logtime}
df = pd.DataFrame(dic).groupby(['Employee ID','Log Date']).agg({'Log Date':'first', 'Log Time': lambda x: ', '.join(x.unique())})['Log Time'].astype(str).str.split(', ', expand=True).reset_index()
Let's say I have a time log like this as the result on the code above:
'7:20', '11:50', '12:49', '17:20'
'7:02', '11:36', '12:59'
'11:33', '12:40', '17:06'
'11:38'
Given the above df, I want to move the row to their specific log sequence, like all 11 am logs are moved to the second column, all 12nn logs are moved to the third column, and all 5 pm logs are on the last column:
AM In AM Out PM In PM Out
'7:20', '11:50', '12:49', '17:20'
'7:02', '11:36', '12:59', ' '
' ', '11:33', '12:40', '17:06'
' ', '11:38', ' ', ' '