2

I have a dateframe that has the total lead values for each product and product family. I want to group this data and get an output that has the count of each product by product family and the sum of order amount.

I am able to do this separately by using

df.groupby(['Product Family', 'Product']).count()

df.groupby(['Product Family', 'Product']).sum()

Is there anyway to combine these two groupby functions so it returns one dataframe?

| Product Family |     Product    | Order Amount|
| -------------- | -------------- | ------------|
| FDA            | CFI            |  1200       |
| Pay            | C-Series       |  800        |
| FDA            | TAP            |  300        |
| HC             | Ink            |  500        |
| Pay            | C-Series       |  8000       |
| HC             | Medica         |  750        |
| PAY            | R-Series       |  3000       |
| HC             | Medica         |  400        |
mtm1186
  • 103
  • 9

0 Answers0