Doon Public School,Etah
Class- XII
Chapter-1 (Data Handling_DataFrame)
Worksheet
1. If a DataFrame is created using a 2-D dictionary then the index/row labels are
formed from__________.
[a] dictinonary’s keys [b] inner dictinonary’s keys
[c] outer dictionary’s keys [d] None of these.
2. The axes 1 identifies a dataframe’s ______________.
3. To get a number representation of a dataframe ___________attribute may be used.
4. To extract row/column from a dataframe_______function may be used.
[a] column( ) [b] loc( ) [c] row () [d] All of the above.
5. To display the 8 ,9 and 10 columns from the 2 to 5 rows of a dataframe DF,
th th th nd th
you can write___________.
[a]DF.loc[2:5.8:10] [b]DF.loc[2:6,8:11] [c] DF.iloc[2:5,8:10] [d] DF.iloc[2:6.8:11]
6. Which among the following options can be used to create a DataFrame in pandas?
[a] ndarray [b] dict [c] scalar value [d] All of these.
7. You can use numpy.______________ for missing data.
8. To access values using row labels you can use DF.__________.
9. To access individual value you can use DF.________ using row/column index labels.
10. To access individual value you can use DF.______ using row/column integer position.
11. The _______ and_______ parameters can be used to change the default row and column labels.
[a] column, row [b] column, index [c] index, column [d] row, column
12. Consider the following code:
import pandas as pd
dict1=[{‘X’:100,’Y’:200}, {‘X’:300,’Z’:400,’W’:500}, {‘Y’:600,’Z’:700,’W’:800}]
df2=pd.DataFrame(dict1)
df2[ : ] =1000
[a] The values of first column will be changed to 1000.
[b] The values of first row will be changed to 1000.
[c] All the values in the dataframe will be changed to 1000.
[d] There will be no changed in the values of the dataframe.
13. Which method or function to add a new row in a dataframe is__________.
[a] .iloc( ) [b] .loc() [c] add () [d] join
14. Pandas dataframe can’t be created using-
[a] Series [b] Dictionary of List [c] List of Dictionary [d] Dictionary of Tuples
15. While accessing the column from the dataframe we can specify the column name. In case
column does not exist, which type of error it will raise?
[a] Key Error [b] Name Error [c] Syntax Error [d] Runtime Error
16. Write the correct syntax to return the values of first row of a dataframe? DataFrame Name:df2
17. Distinguish loc() and iloc ().
18. Write the one line python code to create dataframe df:
import pandas as pd
Name=[‘Manpreet’,’Kapil’,’Manku’] ; Phy =[65,70,67]; Chem=[60,75,72]