32.pandas groupby
Groupby
Create a dataframe
groupby a particular column (company)
sum of sales of every company
mean of sales of a company
standard deviation
sum of sales of a particular company
groupby function -- count, max, min, describe
import pandas as pd
data = {'Company':['GOOG','GOOG','MFST','MFST','FB','FB'],
'Person':['Sam','Charlie','Amy','Vanessa','Carl','Sarah'],
'Sales':[200,120,340,124,243,350]}
df = pd.DataFrame(data)
df
df.groupby('Company')
byComp = df.groupby('Company')
byComp.sum()
byComp.count()
byComp.mean()
byComp.std()
df
byComp.min()
byComp.max()
byComp.max().loc['FB']
byComp.max().loc['FB']['Sales']
byComp.describe()
byComp.describe().transpose()