Easy pandas solution
Code\npythondata []\nimport pandas as pd\n\ndef get_average_time(activity: pd.DataFrame) -> pd.DataFrame:\n    pivoted_df = activity.pivot_table(index=[\'machin
# Code\n```pythondata []\nimport pandas as pd\n\ndef get_average_time(activity: pd.DataFrame) -> pd.DataFrame:\n    pivoted_df = activity.pivot_table(index=[\'machine_id\', \'process_id\'], columns=\'activity_type\', values=\'timestamp\').reset_index()\n    pivoted_df[\'processing_time\'] = pivoted_df[\'end\'] - pivoted_df[\'start\']\n    result = pivoted_df.groupby(\'machine_id\')[\'processing_time\'].mean().round(3).reset_index()\n    return result\n```
['Pandas']