Get statistics for each group (such as count, mean, etc) using pandas GroupBy?

前端 未结 7 1507
无人及你
无人及你 2020-11-21 06:06

I have a data frame df and I use several columns from it to groupby:

df[\'col1\',\'col2\',\'col3\',\'col4\'].groupby([\'col1\',\'co         


        
7条回答
  •  耶瑟儿~
    2020-11-21 06:30

    Create a group object and call methods like below example:

    grp = df.groupby(['col1',  'col2',  'col3']) 
    
    grp.max() 
    grp.mean() 
    grp.describe() 
    

提交回复
热议问题