Skip to main content

Posts

Showing posts with the label Find the sum of each column

ads1

21.Find the sum of each column, or find the column with the lowest mean

  21.Find the sum of each column, or find the column with the lowest mean. Solution :- import pandas as pd  Pass_Perc ={'Phy': {'2017':95.4,'2018':96.4,'2019':99.2,'2020':97.4}, 'Che': {'2017':96.5,'2018':97.4,'2019':100,'2020':99.2},  'Maths': {'2017':90.2,'2018':92.6,'2019':97.4,'2020':98.0}, 'Eng': {'2017':99.2,'2018':100,'2019':100,'2020':100}, 'IP': {'2017':95.6,'2018':100,'2019':100,'2020':100}}  df=pd.DataFrame(Pass_Perc)  print(df)  print()  print('Column wise sum in datframe is :')  print(df.sum(axis=0))  #  Print mean vaLue of each coLumn  print()  print('Column wise mean value are:')  print(df.mean(axis=0).round(1))  #  Returns CoLumn with minimum mean vaLue  print()  print('Column with minimum mean value is:')  print(df.mean(axis=0).idxmin())  Output :-

ads2