I have below dataframe:
week Country Year Value category
1 Angola 2005 6 A
1 Angola 2005 13 A
1 Angola 2005 10 B
1 Angola 2005 11 C
1 Angola 2005 5 D
1 Angola 2006 3 A
1 Angola 2006 2 B
1 Angola 2006 7 C
1 Angola 2006 3 D
1 Angola 2006 6 E
2 Angola 2006 3 A
2 Angola 2006 2 B
2 Angola 2006 7 C
2 Angola 2006 3 D
I want the above data frame to group by week in each year and prepare a pivot in python that gives below data frame. The same data continues for different countries and different categories might be added, if there is new category in any country then that category should be added to the data frame with the respective values in that data frame.
week Country year category_A Category_B category_C category_D Category_E
1 Angola 2005 19 10 11 5 0
1 Angola 2006 3 2 7 3 6
2 Angola 2006 3 2 7 3 0