Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming that the attendance data is in a pandas DataFrame called attendance_df with columns 'Employee ID', 'Timestamp', and 'Status' where 'Status' is 'In' for check-in time and 'Out' for check-out time, we can use the pivot_table() method to obtain the check-in and check-out time for each employee:

# Pivot table to get check-in and check-out times for each employee
pivot_df = attendance_df.pivot_table(index='Employee ID', columns='Status', values='Timestamp')

# Reset index and rename columns
pivot_df = pivot_df.reset_index().rename(columns={'In': 'Check-in Time', 'Out': 'Check-out Time'})

This will create a new DataFrame pivot_df with columns 'Employee ID', 'Check-in Time', and 'Check-out Time' containing the check-in and check-out times for each employee.