Professional Documents
Culture Documents
B0002 Computer Science Move fast with computer science XII Dhanpat Rai 340
Write a program to create a dataframe for the given data, Also Show the DataFrame after deleting details
of BookID : B0004.
(a) To display the details of class XII students in descending order of their marks.
(b) Display the sum of the marks of students who have scored more than 500.
(c) Find the maximum marks of the student for each class.
(d) Count the students class wise and display only those number which is more than 2.
(e) Display unique cities from the table.
SName Amount
H_1 Alexa 7000
H_2 Cortana 5000
H_3 Siri 4000
i. Write a command to display the records of the dataframe which have amount
greater than equal to 5000.
ii. How will you change the index from H_1,H_2,H_3 to 101,102,103
iii). Remove the column Amount.
2.import pandas as pd
dic={'Sname':['Alexa','Cortona','Siri'],'Amount':[7000,5000,4000]}
Humanoid=pd.DataFrame(dic,index=['H_1','H_2','H_3'])
print(Humanoid)
print("--------------------------------------------")
print(Humanoid[Humanoid['Amount']>=5000])
print("--------------------------------------------")
print(Humanoid.rename({'H_1':101,'H_2':102,'H_3':103}))
print("--------------------------------------------")
print(Humanoid.drop('Amount',axis=1))
3. import pandas as pd
d={'Name':['Pawan','Piyush','Prem','Prakash','Prateek'],'Weight':[50,60,40,70,55],'Height':[153,16
5,150,145,160]}
df_data=pd.DataFrame(d,index=['A_1','A_2','A_3','A_4','A_5'])
print(df_data)
print("--------------------------------------------")
print(df_data.iloc[1:4,0:2])
print("--------------------------------------------")
print(df_data[df_data['Name']=='Piyush'])
print("--------------------------------------------")