I have the dataset as follows, which group by ID:
ID, Activity, Duration
1, Reading, 20
1, Work, 40
1, Reading, 30
2, Home, 50
2, Writing, 30
2, Reading, 20
2, Writing, 30
And I want to get another column that tells us the activity with the highest duration, so person 1 should be reading because it takes 50 minutes, and person 2 should be writing because it takes 60 minutes. Below is an example of the desired output.
ID, Activity, Duration, Max_Actitvity
1, Reading, 20, Reading
1, Work, 40, Reading
1, Reading, 30, Reading
2, Home, 50, Writing
2, Writing, 30, Writing
2, Reading, 20, Writing
2, Writing, 30, Writing