I have a dataframe of the following layout:
Quantity
category species
mammal cat 1.75
mammal human 0.25
fish cod 1.5
Where category and species being indexes of this dataframe. I want to get the sum for each category, and concat it into the dataframe.
As a result, I would like to get this:
Quantity
category species
mammal cat 1.75
mammal human 0.25
mammal total 2
fish cod 1.5
fish total 1.5
I'm quite new to pandas, and I've tried playing around sum, concat, and apply without much success. Some help would be very helpful.
Thanks !