SNBP INTERNATIONAL SCHOOL & KIDZONE
SENIOR SECONDARY SCHOOL
MORWADI , PIMPRI, PUNE
CBSE AFFILIATION NO. 1130522
Grade 12
Informatics Practices Worksheet No 3
Operations on rows and columns
1. To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe you
can write
(a) [Link][6:9, 3:5] (b) [Link][6:10, 3:6]
(c) [Link][6:10, 3:6] (d) [Link][6:9, 3:5]
2. To change the 5th column's value at 3rd row as 35 in dataframe DF, you can write
(a) DF[4, 6] = 35 (b) [Link][4, 6] = 35
(c) DF[3, 5] = 35 (d) [Link][3, 5] = 35
3. To delete a column from a DataFrame, you may use statement.
(a) remove (b) del (c) drop (d) cancel statement.
4. To delete a row from a DataFrame, you may use
(a) remove (b) del (c) drop (d) cancel
5. To iterate over horizontal subsets of dataframe,
(a) iterate( ) (b) iterrows( ) function may be used.
(c) itercols( ) (d) iteritems( )
6. To iterate over vertical subsets of a dataframe, function may be used.
(a) iterate( ) (b) iterrows( )
(c) itercols( ) (d) iteritems( )
7. To get top 5 rows of a dataframe, you may use
(a) head( ) (b) head(5) (c) top( ) (d) top(5)
8. Which function is used to rename an existing column or index?
i std() ii hist() iii groupby() iv rename()
Grade 12/IP/Worksheet3/2023-2024
9. In given code dataframe ‘D1’ has ________ rows and ______ columns.
import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20}, {‘a’:7, ‘d’:10, ‘e’:20}] D1
= [Link](LoD)
a. 3, 3 b. 3, 4 c. 3, 5 d. None of the above
10. D1[ : ] = 77 , will set __________ values of a DataFrame ‘D1’ to 77.
a. Only First Row b. Only First Column
c. All d. None of the above
11. Which of the following command will display the column labels of thedataframe?
i) print([Link]()) ii) print([Link]())
iii) print([Link]) iv) print([Link])
12. Write the output of the following code
import pandas as pd
data = [[‘Alex’,10], [‘Bob’,12], [‘Clarke’,13]]
df = [Link](data,columns = [‘Name’ , ‘Age’])
print(df)
[Link] new row banglore with all columns value 1200
[Link].[‘banglore’,:]=1200 [Link][‘banglore’]=1200
[Link][‘banglore’,:]=1200 [Link]=1200
14. Write a Python code to create a dataframe with appropriate headings from the list
given below :
[‘S101’, ‘Amy’ ,70] [‘S102’, ‘Bandhi’ ,69]
[‘S103’, ‘Cathy’ ,75] [‘S104’, ‘Gundoho’ ,82]
Grade 12/IP/Worksheet3/2023-2024