Example
Input:
employee_id,meeting_id,join_time,leave_time
E001,M1,2024-01-15T09:00:00,2024-01-15T10:30:00
E001,M2,2024-01-15T14:00:00,2024-01-15T14:45:00
E002,M3,2024-01-15T10:00:00,2024-01-15T11:00:00
Output:
E001 2024-01-15 1:30:00
E002 2024-01-15 1:00:00
You are given a CSV dataset with these columns:
employee_idmeeting_idjoin_timeleave_timeThe implementation accepts a caller-provided path to a CSV file whose first row is this header and whose subsequent rows contain one meeting per row. For every employee and calendar day, determine that employee's greatest work-duration value. For this task, define “work duration” as the elapsed time of an individual meeting, calculated as leave_time - join_time; meeting time counts as work time.
For every row, treat intersecting meetings as separate meetings: do not merge them or add their overlapping durations. “Longest” means the maximum individual, uninterrupted meeting duration for that employee and day, rather than the sum of durations across the day.
Your implementation should:
The resulting table should have the columns employee_id, day, and longest_work_duration, with one row for each employee and calendar day.
Correct timestamp treatment is the primary source of mistakes. Choose whether to remain in pandas for the full calculation or move to Python dictionaries after reading the data; repeatedly moving between the two approaches may waste effort. Treat all timestamps as using the same timezone, preserve that timezone without conversion, and derive the calendar day from join_time. Treat intersecting meetings as separate intervals, and interpret “longest” as one uninterrupted meeting span rather than a sum for an entire day.
leave_time - join_time.