Pandas solution
I started by changing all start values to negative. \n\nThen I groupby machine_id and process_id and get the sum. Reset_index and drop columns that are not nece
I started by changing all start values to negative. \n\nThen I groupby machine_id and process_id and get the sum. Reset_index and drop columns that are not necessary (activity_type and process_id). \n\nThen perform another groupby using just the machine_id and get the mean for the summed timestamp values. \n\nReset_index again to bring back the machine_id column, rename columns for submission, and round to 3 decimal places.\n\n# Code\n```\nimport pandas as pd\n\ndef get_average_time(activity: pd.DataFrame) -> pd.DataFrame:\n    activity.loc[activity[\'activity_type\'] == \'start\', \'timestamp\'] *= -1\n    return activity.groupby([\'machine_id\', \'process_id\']).sum().reset_index().drop(columns = [\'activity_type\', \'process_id\']).groupby(\'machine_id\').mean().reset_index().rename(columns={\'timestamp\': \'processing_time\'}).round(3)\n```
['Pandas']