Thursday 11 March 2021

Class 12 IP Practical - 23

 

23. Consider the DataFrame (dfmks) given below.

 

A

B

C

D

Acct

99

94.0

92

97.0

Eco

90

94.0

92

97.0

Eng

95

89.0

91

89.0

IP

94

NaN

99

95.0

Math

97

100.0

99

NaN

WAP to print the maximum marks scored in a section, across all subjects.

import pandas as pd

import numpy as np

d={'A':{'Acct':99,'Eco':90,'Eng':95,'IP':94,'Math':97}, \

   'B':{'Acct':94.0,'Eco':94.0,'Eng':89.0,'IP':np.NaN,'Math':100.0}, \

   'C':{'Acct':92,'Eco':92,'Eng':91,'IP':99,'Math':99}, \

   'D':{'Acct':97.0,'Eco':97.0,'Eng':89.0,'IP':95.0,'Math':np.NaN}}

 

dfmks=pd.DataFrame(d)

print("DataFrame is: ")

print(dfmks)

print("Maximum Marks in a section, across all subjects ")

print(dfmks.max(axis=0))

 

>>>

======================= RESTART: C:/Program Files (x86)/Python38-32/IP-22.py ======================

DataFrame is:

       A      B   C     D

Acct  99   94.0  92  97.0

Eco   90   94.0  92  97.0

Eng   95   89.0  91  89.0

IP    94    NaN  99  95.0

Math  97  100.0  99   NaN

Maximum Marks in a section, across all subjects

A     99.0

B    100.0

C     99.0

D     97.0

dtype: float64

>>> 

 

 

No comments:

Post a Comment