I have a dataframe df :
ORDERID PRODUCTTYPE PRODUCTID PRODUCT
123 Fruits 2 Banana
123 Vegetables 3 Tomato
123 Vegetables 3 Onion
321 Fruits 2 Grapes
321 Fruits 2 Avocado
I need output as
ORDERID FRUITS VEGETABLES
123 1 2
321 2 0
Is there any modification i need to perform to the groupby ? I'm doing
df.groupby('ORDERID'['PRODUCTTYPE'].nunique().reset_index(name="count")
but thats just counting the number of categories