Following code gives
Code:
table_channel = pd.pivot_table(data=df,values = 'Category',index =
['ID'], aggfunc='count')
Output:
ID Category
1 2
2 11
3 5
4 3
Right now it's giving total count of different categories of Category column. Need output like:
ID Category1 Category2 Category3
1 0 1 1
2 5 4 2 and so on
I used this code to rectify but it did not work:
table_channel = pd.pivot_table(df,values = 'Category',columns = 'Category',index = ['ID'], aggfunc='count')
Error is that grouper for Category not 1 dimensional. What is wrong?
columnsparameter as well