Practical Implementation of Aggregate Functions in Pandas

Free Pandas course with real-time projects Start Now!!

Program 1

import pandas as pd
product=[('Limca',25,'BK'),('Limca',40,'NM'),('Frooti',20,'AK'),
          ('BMilk',20,'Amul'),('Milk',20,'Amul'),('BMilk',18,'Sanchi'),
          ('Limca',15,'AK'),('Frooti',17,'BK'),('BMilk',23,'Sanchi'),
          ('Milk',27,'NK'),('Frooti',23,'BK'),('BMilk',23,'Sanchi'),
         ]
df=pd.DataFrame(product,columns=['Name','Price','Distb'])
#print(df)
df1=df.groupby('Name')
# for name,rows in df1:
#     print(name)
#     print(rows)
print(df1['Price'].agg(['max','min','mean','count']))

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *