In [1]:
import pandas as pd
In [4]:
dmc = {'Company':['Hyderabad','Hyderabad','Pune','Pune','Chennai','Chennai'],
'Person':['ramesh','Venkat','Praveen','Prasad','Nani','Kiran'],
'Sales':[500,1520,440,334,273,850]}
In [5]:
dmc
Out[5]:
In [6]:
df=pd.DataFrame(dmc)
In [7]:
df
Out[7]:
In [8]:
df.groupby('Company').mean()
Out[8]:
In [9]:
df.groupby('Company')
Out[9]:
In [10]:
gr=df.groupby('Company')
In [11]:
gr.mean()
Out[11]:
In [12]:
gr.max()
Out[12]:
In [13]:
gr.min()
Out[13]:
In [14]:
gr.count()
Out[14]:
In [22]:
gr.describe()
Out[22]:
In [16]:
gr.describe().transpose()
Out[16]:
In [23]:
gr.describe().transpose()
Out[23]:
In [3]:
import pandas as pd
ipl_data = {'Team': ['Riders', 'Riders', 'Devils', 'Devils', 'Kings',
'kings', 'Kings', 'Kings', 'Riders', 'Royals', 'Royals', 'Riders'],
'Rank': [1, 2, 2, 3, 3,4 ,1 ,1,2 , 4,1,2],
'Year': [2014,2015,2014,2015,2014,2015,2016,2017,2016,2014,2015,2017],
'Points':[876,789,863,673,741,812,756,788,694,701,804,690]}
df = pd.DataFrame(ipl_data)
print (df)
In [4]:
df
Out[4]:
In [5]:
df.groupby('Team')
Out[5]:
In [6]:
df.groupby('Team').groups
Out[6]:
No comments:
Post a Comment