🔥[Pandas] very simple 2 step approach 🔥
\n# Approach\n Describe your approach to solving the problem. \n1. Calculate the time spent for each entry\n2. Group by emp_id and event_day, then sum the time_
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Calculate the time spent for each entry\n2. Group by emp_id and event_day, then sum the time_spent\n\n# Code\n```\nimport pandas as pd\n\ndef total_time(employees: pd.DataFrame) -> pd.DataFrame:\n    # Calculate the time spent for each entry\n    employees[\'time_spent\'] = employees[\'out_time\'] - employees[\'in_time\']\n    \n    # Group by emp_id and event_day, then sum the time_spent\n    result = employees.groupby([\'emp_id\', \'event_day\'])[\'time_spent\'].sum().reset_index()\n    result.rename(columns={\'event_day\': \'day\', \'time_spent\': \'total_time\'}, inplace=True)\n    \n    return result\n\n```
['Pandas']