I have a data frame with dates, categories, and time durations. I want to sum the time durations if the entries have the same date and the same category.
Input:
Date Duration Category
01/01/2021 0.1 Entertainment
01/01/2021 1.4 Working
01/01/2021 2.1 Entertainment
02/01/2021 7.9 Sleeping
02/01/2021 1.2 Working
02/01/2021 2.8 Working
04/01/2021 6.2 Sleeping
Output:
Date Entertainment Working Sleeping
01/01/2021 2.2 1.4 0
02/01/2021 0 4.0 7.9
03/01/2021 0 0 0
04/01/2021 0 0 6.2
I have more categories so if you can allow it to easily add new categories. The code I have doesn't work at all so please help me out thanks.