This post is specially created for IP Class 12 Dataframe MCQ. It covers almost all concepts in form of multiple choice questions of 1 mark. These objective type questions with answers are very important and useful for understanding Dataframe and all its concepts. We all know Dataframe is a two dimensional data structure used for storing and managing large and complex data of any type at single place. it can store heterogeneous data. it have two indexes, one for row identification and another for column identification. We can also set user defined indexes for both rows and columns of Dataframe. to use Dataframe we must include python pandas library.
Contents
IP Class 12 Dataframe MCQ Set-2 (Q26-Q50)
- What will be output of the following code?
df = pd.DataFrame([(‘ram’, 80), (‘john’, 70)])
df.columns = [‘name’, ‘marks’]
a) name marks 0 Ram john 1 80 70 b) 0 1 name marks 0 ram 80 NaN NaN 1 john 70 NaN NaN c) name marks 0 ram 80 1 John 70 d) 0 1 0 ram 80 1 john 70 2 name marks
Show Answer
c) name marks 0 ram 80 1 John 70
- Which of the following statement is not correct?
a. iteritems() returns each column’s value in form of series object.
b. tail() returns any no of bottom rows by specifying values of nos. argument.
c. Transpose of dataframe is available through <dataframe>. T
d. Python integer type can store NaN values.
Show Answer
d. Python integer type can store NaN values.
- What will be output of the following code?
list1 = [[10,20], [30,40], [50,60]]
df = pd.DataFrame(list1)
print(df)
a) 10 20 b) 0 1 c) 0 1 d) 0 1 2 0 30 40 10 30 50 0 10 20 0 10 30 50 1 50 60 20 40 0 1 30 40 1 20 40 60 2 50 60
Show Answer
c) 0 1 0 10 20 1 30 40 2 50 60
- To count total no of rows in a dataframe we use
a. count()
b. len()
c. values
d. all of above
Show Answer
b. len()
- Which of the following is Missing data?
a. NULL
b. NaN
c. None
d. All Above
Show Answer
d. All Above
- To access individual item from dataframe ‘df’ which of the following is Not correct?
a. df.loc[2,2]
b. df.iat[2,2]
c. df.at[2,2]
d. df[0,0]
Show Answer
d. df[0,0]
- Which of the following is not a iterative function for dataframe?
a. iterrows()
b. iteritems()
c. itercolumns()
d. none
Show Answer
c. itercolumns()
- For given dataframe ‘df’
A B
0 15 18
1 20 25
2 40 50
3 70 44
What will be output of the following code?
df.tail(2)
a) A B b) A B c) A B d) None 3 70 44 2 40 50 1 20 25 2 40 50 3 70 44 0 15 18
Show Answer Show Answer a. emp.sal[200,300] Show Answer d. By default in drop function of dataframe object value of axis is 1 always. Show Answer a. first five rows of dataframe Show Answer c. iloc ename dept Which type of error following code will produce: a. key error Show Answer b. value error Show Answer c. book.drop([‘pub’], axis = 1) Show Answer d. to access individual data from a dataframe, we can use row index with ‘ Show Answer a. df.T boys girls subject awards Which of the following is not correct? Show Answer d. loc[‘boy’] Show Answer c. count A B Show Answer Show Answer b. both are true Show Answer Show Answer boys girls subject awards a. All are correct Show Answer a. All are correct Show Answer b. loc Show Answer a. Unionb) A B
2 40 50
3 70 44
a. emp.sal[200,300]
b. emp.loc[:,‘sal’]=[200,300]
c. emp = emp.assign(‘sal’=[200,300])
d. emp.at[:, ‘sal’] = [200,300]
a. When values are assigned to column of dataframe for non-existing columns, it will add a new column.
b. in iloc, like slices end index/position is excluded when given as start: end
c. While creating a dataframe from 2D dictionary, keys of all inner dictionaries must be same in number or name.
d. By default in drop function of dataframe object value of axis is 1 always.
a. first five rows of dataframe
b. all rows of a dataframe
c. first row of dataframe
d. nothing will be displayed
a. loc
b. at
c. iloc
d. df.<col_lable>
e1 a.k. om
e2 m.s. ee
emp.loc[:, “sal”] = [200,300,400]
b. value error
c. syntax error
d. no error
book.drop(‘pub’)
But she is not getting desire output, help her to select correct statement.
a. book.drop([‘pub’])
b. book.drop([‘pub’], axis = 0)
c. book.drop([‘pub’], axis = 1)
d. none
a. with iloc, both start index and end index are included in result
b. with loc, like slices end label is excluded from result.
c. with iat, we can access individual value for a row/column label pair.
d. to access individual data from a dataframe, we can use row index with ‘ <dataframe>.column[]’ in square bracket.
df = pd.DataFrame(dict1)
But she doesn’t know how to transpose dataframe, help her to do so.
a. df.T
b df.t
c. df.Transpose
d. df.Transpose()
class1 24 16 5 8
class2 20 20 5 10
class3 18 33 6 13
class4 21 19 6 9
a. loc[‘class1’, : ]
b. loc[ : , ‘boy’]
c. loc[‘class1’]
d. loc[‘boy’]
a. size
b. len
c. count
d. values
0 15 18
1 20 25
2 40 50
3 70 44
What will be output of the following code?
print(df[‘A’] = 40]
a) A b) A c) A d) A
0 15 2 40 0 False 0 40
1 20 1 False 1 40
2 40 2 True 2 40
3 70 3 False 3 40d) A
0 40
1 40
2 40
3 40
(ii) the axis = 1 identifies the column index of dataframe
a. both are false
b. both are true
c. (i) true (ii) false
d. (i) false (ii) true
d1 = {‘A’:10, ‘B’:20}
d2 = {‘A’:50, ‘C’:30}
d = {‘i’:d1, ‘ii’:d2}
df = pd.DataFrame(d)
print(df)a) i ii b) i ii c) A B C d) A B C
A 10 50 A 10 NaN i 10 20 NaN i 10 50 NaN
B 20 NaN B 50 20 ii 50 NaN 30 ii 20 NaN 30
C NaN 30 C NaN 30
a) i ii
A 10 50
B 20 NaN
C NaN 30
dict = {‘bookname’ : [‘C’,’C++’], ‘author’: [‘kanitkar’,’balaguruswami’]}
df = pd.DataFrame(dict, index = [1,2])
print(df)a) bookname author b) author bookname
0 C kanitkar 0 kanitkar C
1 C++ balaguruswami 1 balaguruswami C++
c) bookname author d) author bookname
1 C kanitkar 1 kanitkar C
2 C++ balaguruswami 2 balaguruswami C++
c) bookname author
1 C++ balaguruswami
2 C kanitkar
class1 24 16 5 8
class2 20 20 5 10
class3 18 33 6 13
class4 21 19 6 9
To display first two columns and two rows which of the following code are correct?
b. All are incorrect
c. (1) and (3) are correct
d. (3) and (4) are correct
a. at
b. loc
c. iat
d. iloc
a. Union
b. Intersection
c. Product
d. SumIP Class 12 Dataframe MCQ Set-1 (Q1-25)
IP Class 12 Dataframe MCQ Set-3 (Q51-75)
Set-4 (Q76-100)
IP Class 12 MCQ