Groupby difference function using packet Series and Dataframe

1. Dataframe packet with GroupBy ( "column name") or GroupBy ([ "column name 1", "2 column name"])

import pandas as pd
DF = pd.DataFrame ({ ' Sex ' : [ ' M ' , ' F ' , ' M ' , ' F ' ,
                             ' M ' , ' F ' , ' M ' , ' M ' ],
                    ' performance ' : [ ' excellent ' , ' good ' , 'Pass ' , 'Difference ' ,
                             ' pass ' , ' pass ' , ' excellent ' , ' difference ' ],
                    ' Age ' : [15,14,15,12,13,14,15,16 ]})
df

= df.groupby COUNT ([ " Sex " , " Age " ]). COUNT ()
count

= df.groupby COUNT ( " sex " ) .count ()
count

 

 2. Series packet with groupby (Series)

import pandas as pd
DS = pd.Series ({ ' Bob ' : ' M ' , ' Zhang ' : ' M ' , ' Zhao ' : ' M ' })
GroupBy=ds.groupby(ds)
GroupBy.describe()

 

 

 

Guess you like

Origin www.cnblogs.com/wqbin/p/11808570.html