0% found this document useful (0 votes)
2K views2 pages

Grade 12 - Data Handling Using Pandas 1-Worksheet 3

The document is a worksheet for a Grade 12 Informatics Practices class. It contains 14 multiple choice questions related to operations on rows and columns of dataframes in Python, including selecting subsets of data, modifying values, iterating over rows and columns, and adding/deleting rows and columns. It also provides sample code for creating and printing a dataframe from a list of lists.

Uploaded by

10B Zoya Gous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views2 pages

Grade 12 - Data Handling Using Pandas 1-Worksheet 3

The document is a worksheet for a Grade 12 Informatics Practices class. It contains 14 multiple choice questions related to operations on rows and columns of dataframes in Python, including selecting subsets of data, modifying values, iterating over rows and columns, and adding/deleting rows and columns. It also provides sample code for creating and printing a dataframe from a list of lists.

Uploaded by

10B Zoya Gous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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) DF.loc[6:9, 3:5] (b) DF.loc[6:10, 3:6]
(c) DF.iloc[6:10, 3:6] (d) DF.iloc[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) DF.iat[4, 6] = 35
(c) DF[3, 5] = 35 (d) DF.iat[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
= pd.DataFrame(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(df.columns()) ii) print(df.column())
iii) print(df.column) iv) print(df.columns)

12. Write the output of the following code


import pandas as pd
data = [[‘Alex’,10], [‘Bob’,12], [‘Clarke’,13]]
df = pd.DataFrame(data,columns = [‘Name’ , ‘Age’])
print(df)

13.Add new row banglore with all columns value 1200

a.df.[‘banglore’,:]=1200 b.df.at[‘banglore’]=1200

c.df.at[‘banglore’,:]=1200 d.df.at.banglore=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

You might also like