Practical Implementation of Aggregate Functions in Pandas
Get Job-Ready: Data Analysis using Python with 70+ 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']))
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

