Here is how it works in Oracle. I'm looking for a neat equivalent in pandas, preferably integrated with the rendering of the DataFrame to python notebook. The gist of GROUP BY ROLLUP is that if you group by multiple columns you will also see aggregates as if grouped by subsets of these columns.
            Asked
            
        
        
            Active
            
        
            Viewed 9,581 times
        
    2
            
            
        - 
                    Take a look at this answer. Is this what you're after? http://stackoverflow.com/questions/15570099/pandas-pivot-tables-row-subtotals/15574875#15574875 – Bob Haffner Feb 20 '15 at 13:16
- 
                    @BobHaffner Yep, thats it. You can promote this to an answer, because most people with background in sql would be looking for it by the ROLLUP keyword. Thank you. – JohnnyM Feb 20 '15 at 13:31
1 Answers
4
            Refer to this answer Pandas Pivot tables row subtotals
It uses pivot_table() with margins=True to add a totals column
Then some reshaping of the pivot_table through the use of stack()
Not as slick as group by rollup, but it works
 
    
    
        Community
        
- 1
- 1
 
    
    
        Bob Haffner
        
- 8,235
- 1
- 36
- 43
