Grade 12 - Data Handling Using Pandas 1-Worksheet 3
Grade 12 - Data Handling Using Pandas 1-Worksheet 3
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
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
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)
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 :
Grade 12/IP/Worksheet3/2023-2024