Practical Implementation of Pandas Groupby Function
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=['Product_Name','Proudct_Price','Distributor']) df1=df.groupby('Product_Name') # for name,rows in df1: # print(name) # print(rows) #print(df1.get_group('BMilk').min()) # print(df1.count()) print(df1.agg())
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google