0

Details about data

Order Id: order id is generated when a customer orders anything product is the items that she is ordering

I want a count matrix wherein how many orders lemon and apple combination was, their input data is enter image description here

I tried groupby

.groupby(\['product', 'order_id'\]).size().unstack(fill_value=0))

I am expecting the results to be

enter image description here

Faisal Nazik
  • 2,367
  • 4
  • 17
  • 40
  • maybe you are searching for the `count` aggregation function? if thats not the case could you please provide a minimal input data example. – Exciter Mar 30 '22 at 07:43
  • what is the difference between input and output? also where are the lemons? Seems like a poorly crafted question to me – mozway Mar 30 '22 at 07:49
  • input is order_id product 7930060 Lemon 7930060 Apple 7930060 Strawberry 7930060 Guava 7703566 Lemon 7703566 Apple 7703566 Banana 2703598 Lemon 2703598 Apple 2703598 Rose 2703598 Strawberry and output I am expecting Lemon Apple Strawberry Guava Banana Rose Lemon 3 3 2 1 1 1 Apple 3 3 2 1 1 1 Strawberry 2 2 2 0 0 1 Guava 0 1 1 1 0 0 Banana 1 1 0 0 1 0 Rose 1 1 1 0 0 1 – sahil goyal Mar 30 '22 at 09:48

0 Answers0