100 Important Python dataframe MCQ Class 12 IP

Python dataframe MCQ Class 12

Python DataFrame
Python DataFrame MCQ

Click For

PANDAS SERIES MCQ

PANDAS DATAFRAME MCQ


Click For

PANDAS SERIES MCQ

DATA VISUALIZATION MCQ


Python dataframe MCQ Class 12

Q1. In Pandas _______________ is used to store data in multiple columns.

a. Series

b. DataFrame

c. Both of the above

d. None of the above

[showhide type=”links1″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DataFrame [/showhide]

Q2. A _______________ is a two-dimensional labelled data structure .

a. DataFrame

b. Series

c. List

d. None of the above

[showhide type=”links2″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DataFrame [/showhide]

Q3. _____________ data Structure has both a row and column index.

a. List

b. Series

c. DataFrame

d. None of the above

[showhide type=”links3″ more_text=”Show Answer” less_text=”Hide Answer”]Ans. c. DataFrame [/showhide]

Q4. Which library is to be imported for creating DataFrame?

a. Python

b. DataFrame

c. Pandas

d. Random

[showhide type=”links4″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Pandas [/showhide]

Q5. Which of the following function is used to create DataFrame?

a. DataFrame( )

b. NewFrame( )

c. CreateDataFrame( )

d. None of the Above

[showhide type=”links5″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DataFrame( ) [/showhide]

Python dataframe MCQ Class 12

Q6. The following code create a dataframe named ‘D1’ with _______________ columns.

import pandas as pd
D1 = pd.DataFrame([1,2,3] )

a. 1

b. 2

c. 3

d. 4

[showhide type=”links6″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. 1 [/showhide]

Q7. We can create DataFrame from _____

a. Numpy arrays

b. List of Dictionaries

c. Dictionary of Lists

d. All of the above

[showhide type=”links7″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. All of the above [/showhide]

Q8. Which of the following is used to give user defined column index in DataFrame?

a. index

b. column

c. columns

d. colindex

[showhide type=”links8″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. columns [/showhide]

Q9. The following code create a dataframe named ‘D1’ with ___________ columns.

import pandas as pd
LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20}]
D1 = pd.DataFrame(LoD)

a. 1

b. 2

c. 3

d. 4

[showhide type=”links9″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. 3 [/showhide]

Q10. The following code create a dataframe named ‘D1’ with ______ rows.

import pandas as pd
LoD = [{'a':10, 'b':20}, {'a':5, 'b':10, 'c':20}]
D1 = pd.DataFrame(LoD)

a. 0

b. 1

c. 2

d. 3

[showhide type=”links10″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. 2 [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=180]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Python DataFrame
Python DataFrame MCQ

Python dataframe MCQ Class 12

Q11. When we create DataFrame from List of Dictionaries, then dictionary keys will become ____________

a. Column labels

b. Row labels

c. Both of the above

d. None of the above

[showhide type=”links11″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. Column labels [/showhide]

Q12. When we create DataFrame from List of Dictionaries, then number of columns in DataFrame is equal to the _______

a. maximum number of keys in first dictionary of the list

b. maximum number of different keys in all dictionaries of the list

c. maximum number of dictionaries in the list

d. None of the above

[showhide type=”links12″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. maximum number of different keys in all dictionaries of the list [/showhide]

Q13. When we create DataFrame from List of Dictionaries, then number of rows in DataFrame is equal to the ____________

a. maximum number of keys in first dictionary of the list

b. maximum number of keys in any dictionary of the list

c. number of dictionaries in the list

d. None of the above

[showhide type=”links13″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. number of dictionaries in the list [/showhide]

Q14. 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

[showhide type=”links14″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. 3, 5 [/showhide]

Q15. When we create DataFrame from Dictionary of List then Keys becomes the _____________

a. Row Labels

b. Column Labels

c. Both of the above

d. None of the above

[showhide type=”links15″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. Column Labels [/showhide]

Python dataframe MCQ Class 12

Q16. When we create DataFrame from Dictionary of List then List becomes the ________________

a. Row Labels

b. Column Labels

c. Values of rows

d. None of the above

[showhide type=”links16″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Values of rows [/showhide]

Q17. In given code dataframe ‘D1’ has _____ rows and ______ columns.

import pandas as pd
LoD = {“Name” : [“Amit”, “Anil”,”Ravi”], “RollNo” : [1,2,3]}
D1 = pd.DataFrame(LoD)

a. 3, 3

b. 3, 2

c. 2, 3

d. None of the above

[showhide type=”links17″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. 3, 2 [/showhide]

Q18. We can create a DataFrame using a single series. (T/F)

a. True

b. False

[showhide type=”links18″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. True [/showhide]

Q19. DataFrame created from single Series has ____ column.

a. 1

b. 2

c. n (Where n is the number of elements in the Series)

d. None of the above

[showhide type=”links19″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. 1 [/showhide]

Q20. In given code dataframe ‘D1’ has _____ rows and _____ columns.

import pandas as pd
S1 = pd.Series([1, 2, 3, 4], index = ['a', 'b','c','d'])
S2 = pd.Series([11, 22, 33, 44], index = ['a', 'bb','c','dd'])
D1 = pd.DataFrame([S1,S2])

a. 2, 4

b. 4, 6

c. 4, 4

d. 2, 6

[showhide type=”links20″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. 2, 6 [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=181]Click here to check your performance in Python DataFrame [/qsm_link]


Python dataframe MCQ Class 12

Q21. In DataFrame, by default new column added as the _____________ column

a. First (Left Side)

b. Second

c. Last (Right Side)

d. Random

[showhide type=”links21″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Last (Right Side) [/showhide]

Q22. We can add a new row to a DataFrame using the _____________ method

a. rloc[ ]

b. iloc[ ]

c. loc[ ]

d. None of the above

[showhide type=”links22″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. loc[ ] [/showhide]

Q23. D1[ : ] = 77 , will set __________ values of a Data Frame ‘D1’ to 77.

a. Only First Row

b. Only First Column

c. All

d. None of the above

[showhide type=”links23″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. All [/showhide]

Q24. In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will _____________

D1['Rollno'] = [1,2,3] #There are only three rows in DataFrame D1'

a. Return error

b. Replace the already existing values.

c. Add new column

d. None of the above

[showhide type=”links24″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. Replace the already existing values. [/showhide]

Q25. In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________

D1['Rollno'] = [1, 2] #There are only three rows in DataFrame D1'

a. Return error

b. Replace the already existing values.

c. Add new column

d. None of the above

[showhide type=”links25″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. Return error [/showhide]

Python dataframe MCQ Class 12

Q26. In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________

D1['Rollno'] = 11

a. Return error

b. Change all values of column Roll numbers to 11

c. Add new column

d. None of the above

[showhide type=”links26″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. Change all values of column Roll numbers to 11 [/showhide]

Q27. DF1.loc[ ] method is used to ______ # DF1 is a DataFrame

a. Add new row in a DataFrame ‘DF1’

b. To change the data values of a row to a particular value

c. Both of the above

d. None of the above

[showhide type=”links27″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q28. Which method is used to delete row or column in DataFrame?

a. delete( )

b. del( )

c. drop( )

d. None of the above

[showhide type=”links28″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. drop( ) [/showhide]

Q29. To delete a row, the parameter axis of function drop( ) is assigned the value ______________

a. 0

b. 1

c. 2

d. 3

[showhide type=”links29″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. 0 [/showhide]

Q30. To delete a column, the parameter axis of function drop( ) is assigned the value _____________

a. 0

b. 1

c. 2

d. 3

[showhide type=”links30″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. 1 [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=182]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Q31. The following statement will _________

df = df.drop(['Name', 'Class', 'Rollno'], axis = 1) #df is a DataFrame object

a. delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’

b. delete three rows having labels ‘Name’, ‘Class’ and ‘Rollno’

c. delete any three columns

d. return error

[showhide type=”links31″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’ [/showhide]

Q32. If the DataFrame has more than one row with the same label, then DataFrame.drop( ) method will delete _____

a. first matching row from it.

b. all the matching rows from it

c. last matching row from it.

d. Return Error

[showhide type=”links32″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. all the matching rows from it [/showhide]

Q33. Write the code to remove duplicate row labelled as ‘R1’ from DataFrame ‘DF1’

a. DF1 = DF1.drop(‘R1’, axis = 0)

b. DF1 = DF1.drop(‘R1’, axis = 1)

c. DF1 = DF1.del(‘R1’, axis = 0)

d. DF1 = DF1.del(‘R1’, axis = 1)

[showhide type=”links33″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF1 = DF1.drop(‘R1’, axis = 0) [/showhide]

Q34. Which method is used to change the labels of rows and columns in DataFrame?

a. change( )

b. rename( )

c. replace( )

d. None of the above

[showhide type=”links34″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. rename( ) [/showhide]

Q35. The parameter axis=’index’ of rename( ) function is used to specify that the ________

a. row and column label is to be changed

b. column label is to be changed

c. row label is to be changed

d. None of the above

[showhide type=”links35″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. row label is to be changed [/showhide]

Python dataframe MCQ Class 12

Q36. What will happen if in the rename( ) function we pass only a value for a row label that does not exist?

a. it returns an error.

b. matching row label will not change .

c. the existing row label will left as it is.

d. None of the above

[showhide type=”links36″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. the existing row label will left as it is. [/showhide]

Q37. What value should be given to axis parameter of rename function to alter column name?

a. column

b. columns

c. index

d. None of the above

[showhide type=”links37″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. columns [/showhide]

Q38. The following statement is __________

>>> DF=DF.rename({‘Maths’:’Sub1′,‘Science’:’Sub2′}, axis=’index’) #DF is a DataFrame

a. altering the row labels

b. altering the column labels

c. altering the row and column labels (both)

d. Error

[showhide type=”links38″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. altering the row labels [/showhide]

Q39. Q39. Write a statement to delete column labelled as ‘R1’ of DataFrame ‘DF’..

a. DF= DF.drop(‘R1’, axis=0)

b. DF= DF.del(‘R1’, axis=0)

c. DF= DF.drop(‘R1’, axis=0, row = ‘duplicate’)

d. None of the above

[showhide type=”links39″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. None of the above [/showhide]

Q40. Which of the following parameter is used to specify row or column in rename function of DataFrame?

a. rowindex

b. colindex

c. Both of the above

d. index

[showhide type=”links40″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. index [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=192]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Q41. Which of the following are ways of indexing to access Data elements in a DataFrame?

a. Label based indexing

b. Boolean Indexing

c. All of the above

d. None of the above

[showhide type=”links41″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. All of the above [/showhide]

Q42. DataFrame.loc[ ] is an important method that is used for ____________ with DataFrames

a. Label based indexing

b. Boolean based indexing

c. Both of the above

d. None of the above

[showhide type=”links42″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. Label based indexing [/showhide]

Q43. The following statement will return the column as a _______

>>> DF.loc[: , 'Name'] #DF is a DataFrame object

a. DataFrame

b. Series

c. List

d. Tuple

[showhide type=”links43″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. Series [/showhide]

Q44. The following two statement will return _______________

>>> DF.loc[:,'Name'] #DF is a DataFrame object
>>> DF['Name'] #DF is a DataFrame object

a. Same Output

b. Name column of DataFrame DF

c. Both of the above

d. Different Output

[showhide type=”links44″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q45. The following statement will display ________ rows of DataFrame ‘DF’

print(df.loc[[True, False,True]])

a. 1

b. 2

c. 3

d. 4

[showhide type=”links45″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. 2 [/showhide]

Python dataframe MCQ Class 12

Q46. We can use the ______ method to merge two DataFrames

a. merge( )

b. join( )

c. append( )

d. drop( )

[showhide type=”links46″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. append( ) [/showhide]

Q47. We can merge/join only those DataFrames which have same number of columns.(T/F)

a. True

b. False

[showhide type=”links47″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. False [/showhide]

Q48. What we are doing in the following statement?

dF1=dF1.append(dF2) #dF1 and dF2 are DataFrame object

a. We are appending dF1 in dF2

b. We are appending dF2 in dF1

c. We are creating Series from DataFrame

d. None of the above

[showhide type=”links48″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. We are appending dF2 in dF1 [/showhide]

Q49. ______________ parameter is used in append( ) function of DataFrame to get the column labels in sorted order.

a. sorted

b. sorter

c. sort

d. None of the above

[showhide type=”links49″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. sort [/showhide]

Q50. ________ parameter of append( ) method may be set to True when we want to raise an error if the row labels are duplicate.

a. verify_integrity

b. verifyintegrity

c. verify.integrity

d. None of the above

[showhide type=”links50″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. verify_integrity [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=193]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Q51. The ________________parameter of append() method in DataFrame may be set to True, when we do not want to use row index labels.

a. ignore_index_val

b. ignore_index_value

c. ignore_index

d. None of the above

[showhide type=”links51″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. ignore_index [/showhide]

Q52. The append() method of DataFrame can also be used to append ____________to a DataFrame

a. Series

b. Dictionary

c. Both of the above

d. None of the above

[showhide type=”links52″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q53. Which of the following attribute of DataFrame is used to display row labels?

a. columns

b. index

c. dtypes

d. values

[showhide type=”links53″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. index [/showhide]

Q54. Which of the following attribute of DataFrame is used to display column labels?

a. columns

b. index

c. dtypes

d. values

[showhide type=”links54″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. columns [/showhide]

Q55. Which of the following attribute of DataFrame is used to display data type of each column in DataFrame?

a. Dtypes

b. DTypes

c. dtypes

d. datatypes

[showhide type=”links55″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. dtypes [/showhide]

Python dataframe MCQ Class 12

Q56. Which of the following attribute of DataFrame display all the values from DataFrame?

a. values

b. Values

c. val

d. Val

[showhide type=”links56″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. values [/showhide]

Q57. Which of the following attribute of DataFrame display the dimension of DataFrame

a. shape

b. size

c. dimension

d. values

[showhide type=”links57″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. shape [/showhide]

Q58. If the following statement return (5, 3) it means _____

>>> DF.shape #DF is a DataFrame object

a. DataFrame DF has 3 rows 5 columns

b. DataFrame DF has 5 rows 3 columns

c. DataFrame DF has 3 rows 5 rowlabels

d. None of the above

[showhide type=”links58″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DataFrame DF has 5 rows 3 columns [/showhide]

Q59. Transpose the DataFrame means _____________

a. Row indices and column labels of the DataFrame replace each other’s position

b. Doubling the number of rows in DataFrame

c. Both of the above

d. None of the above

[showhide type=”links59″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. Row indices and column labels of the DataFrame replace each other’s position [/showhide]

Q60. Which of the following is used to display first 2 rows of DataFrame ‘DF’?

a. DF.head( )

b. DF.header(2)

c. DF.head(2)

d. None of the above

[showhide type=”links60″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.head(2) [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=194]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Q61. Which of the following statement is Transposing the DataFrame ‘DF1’?

a. DF1.transpose

b. DF1.T

c. DF1.Trans

d. DF1.t

[showhide type=”links61″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF1.T [/showhide]

Q62. Following statement will display ___________ rows from DataFrame ‘DF1’.

>>> DF1.head()

a. All

b. 2

c. 3

d. 5

[showhide type=”links62″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. 5 [/showhide]

Q63. Which of the following function display the last ‘n’ rows from the DataFrame?

a. head( )

b. tail( )

c. Tail( )

d. None of the above

[showhide type=”links63″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. tail( ) [/showhide]

Q64. Which property of dataframe is used to check that dataframe is empty or not?

a. isempty

b. IsEmpty

c. empty

d. Empty

[showhide type=”links64″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. empty [/showhide]

Q65. Write the output of the statement >>>df.shape , if df has the following structure.

      Name     Class      Rollno
0    Amit       6                  1
1    Anil         7                  2
2    Ravi        8                  3

a. (3, 4)

b. (4, 3)

c. (3, 3)

d. None of the above

[showhide type=”links65″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. (3, 3) [/showhide]

Python dataframe MCQ Class 12

Q66. Write the output of the statement >>>df.size , if df has the following structure:

      Name     Class      Rollno
0    Amit       6                  1
1    Anil         7                  2
2    Ravi        8                  3

a. 9

b. 12

c. 6

d. None of the above

[showhide type=”links66″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. 9 [/showhide]

Q67. Write the output of the statement >>>df.empty , if df has the following structure:

      Name     Class      Rollno
0    Amit       6                  1
1    Anil         7                  2
2    Ravi        8                  3

a. True

b. False

c. Yes

d. None of the above

[showhide type=”links67″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. False [/showhide]

Q68. Parameters of read_csv( ) function is _____

a. sep

b. header

c. Both of the above

d. None of the above

[showhide type=”links68″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q69. Which of the following function is used to load the data from the CSV file into a DataFrame?

a. read.csv( )

b. readcsv( )

c. read_csv( )

d. Read_csv( )

[showhide type=”links69″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. read_csv( ) [/showhide]

Q70. The default value for sep parameter is _________

a. comma

b. semicolon

c. space

d. None of the above

[showhide type=”links70″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. space [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=195]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Q71. Write statement to display the row labels of ‘DF’.

a. DF.Index

b. DF.index( )

c. DF.index

d. DF.row_index

[showhide type=”links71″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.index [/showhide]

Q72. Write statement to display the column labels of DataFrame ‘DF’

a. DF.Column

b. DF.column

c. DF.columns

d. DF.Columns

[showhide type=”links72″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.columns [/showhide]

Q73. Display first row of dataframe ‘DF’

a. print(DF.head(1))

b. print(DF[0 : 1])

c. print(DF.iloc[0 : 1])

d. All of the above

[showhide type=”links73″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. All of the above [/showhide]

Q74. Display last two rows from dataframe ‘DF’

a. print(DF[-2 : -1])

b. print(DF.iloc[-2 : -1])

c. print(DF.tail(2))

d. All of the above

[showhide type=”links74″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. print(DF.tail(2)) [/showhide]

Q75. Write statement to display the data types of each column of dataframe ‘DF’.

a. DF.types( )

b. DF.dtypes

c. DF.dtypes( )

d. None of the above

[showhide type=”links75″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF.dtypes [/showhide]

Python dataframe MCQ Class 12

Q76. Write statement to display the dimension of dataframe ‘DF’.

a. DF.dim

b. DF.ndim

c. DF.dim( )

d. None of the above

[showhide type=”links76″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF.ndim [/showhide]

Q77. Write statement to transpose dataframe DF.

a. DF.T

b. DF.transpose

c. DF.t

d. DF.T( )

[showhide type=”links77″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF.T [/showhide]

Q78. Write statement to display first two columns of dataframe ‘DF’.

a. DF[DF.columns[ 0 : 2 ] ]

b. DF.columns[ 0 : 2 ]

c. Both of the above

d. None of the above

[showhide type=”links78″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF[DF.columns[ 0 : 2 ] ] [/showhide]

Q79. Write statement to display the shape of dataframe ‘DF’.

a. DF.Shape

b. DF.shape

c. DF.shapes

d. DF.Shapes

[showhide type=”links79″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF.shape [/showhide]

Q80. Write a statement to Check if DF is empty or it contains data.

a. DF.Empty

b. DF.empty( )

c. DF.empty

d. None of the above

[showhide type=”links80″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.empty [/showhide]

Python dataframe MCQ Class 12


[qsm_link id=196]Click here to check your performance in Python DataFrame[/qsm_link]


Python dataframe MCQ Class 12

Consider the DataFrame ‘DF’ given below and answer the questions from Q81 to Q90. Following DataFrame ‘DF’ containing
year wise sales figures for five sales persons

2014201520162017
Madhu100.5120002000050000
Kusum150.8180005000060000
Kinshuk200.9220007000070000
Ankit30000300001000080000
Shruti400004500012500090000
Python DataFrame ‘DF’

Q81. Write a statement to append the DataFrame ‘DF2’ to the DataFrame ‘DF’

a. DF.append(DF2)

b. DF2.append(DF)

c. DF2.update(DF)

d. None of the above

[showhide type=”links81″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF.append(DF2) [/showhide]

Q82. Write a statement to display the sales made by all sales persons in the year 2017.

a. print(DF.loc[: , 2017])

b. print(DF[2017])

c. Both of the above

d. None of the above

[showhide type=”links82″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. print(DF.loc[2017]) [/showhide]

Q83. Write a statement to add new column for another year ‘2018’ with values 55000, 65000, 75000, 85000, 95000

a. DF[2018] = 55000, 65000, 75000, 85000, 95000

b. DF[2018] = [55000, 65000, 75000, 85000, 95000]

c. DF[2018] = (55000, 65000, 75000, 85000, 95000)

d. All of the above

[showhide type=”links83″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. d. All of the above [/showhide]

Q84. Write a statement to add new row for ‘Raman’ with values 55000, 66000, 77000, 88000

a. DF.loc[‘Raman’] = 55000, 66000, 77000, 88000

b. DF.loc[‘Raman’] = [55000, 66000, 77000, 88000]

c. Both of the above

d. None of the above

[showhide type=”links84″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q85. Raman was caught in the case of cheating so his Boss decided to set his sales of all years to 0(Zero). Help him to write the code for same.

a. DF.loc[‘Raman’] = {0}

b. DF.loc[‘Raman’] = [0]

c. DF.loc[‘Raman’] = 0

d. All of the above

[showhide type=”links85″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.loc[‘Raman’] = 0 [/showhide]

Python dataframe MCQ Class 12

Q86. Write a statement to delete the record of ‘Shruti’

a. print(DF.drop(‘Shruti’,axis=0))

b. print(DF.drop(‘Shruti’))

c. both of the above

d. none of the above

[showhide type=”links86″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. both of the above [/showhide]

Q87. Write a statement to delete a column having column label as 2017.

a. print(DF.drop(2017,axis=0))

b. print(DF.drop(2017,axis=1))

c. print(DF.drop(‘2017’,axis=1))

d. All of the above

[showhide type=”links87″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. print(DF.drop(2017,axis=1)) [/showhide]

Q88. Write a statement to delete two columns having column label as 2017 and 2016

a. print(DF.drop([2017, 2016], axis=1))

b. print(DF.drop((2017, 2016), axis=1))

c. Both of the above

d. print(DF.drop([2017,2016],axis=0))

[showhide type=”links88″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. print(DF.drop([2017, 2016], axis=1)) [/showhide]

Q89. Replace the row label ‘Ankit’ with ‘Ankita’ in dataframe ‘DF’

a. DF.Rename({‘Ankit’ : ‘Ankita’})

b. DF.rename({‘Ankit’ : ‘Ankita’})

c. DF.repalce({‘Ankit’:’Ankita’})

d. None of the above

[showhide type=”links89″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF.rename({‘Ankit’ : ‘Ankita’}) [/showhide]

Q90. Replace the column label from 2016 to 2020.

a. DF.rename({2016 : 2020}, axis = ‘columns’)

b. DF.rename({2016 : 2020}, axis = ‘index’)

c. DF.rename({2016 : 2020}, axis = ‘column’)

d. DF.rename({2016 : 2020}, axis = columns)

[showhide type=”links90″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF.rename({2016 : 2020},axis = ‘columns’) [/showhide]

Python dataframe MCQ Class 12

Consider the DataFrame ‘DF’ given below and answer the questions from Q91 to Q100. Following DataFrame ‘DF’ containing marks of five students in three subjects.

HarryKiranAnujKaranRounaq
Science8582656090
Maths9095858075
English8085757060
Python DataFrame

Q91. Display the marks of Harry in Maths Subject.

a. print(DF.loc[‘Maths’, ‘Harry’])

b. print(DF.Loc[‘Maths’, ‘Harry’])

c. print(DF.loc(‘Maths’, ‘Harry’))

d. None of the above

[showhide type=”links91″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF.loc[‘Maths’, ‘Harry’] [/showhide]

Q92. Display the marks of Karan in all Subjects

a. print(DF.loc[‘Science’ : ‘English’, ‘Karan’])

b. print(DF[‘Karan’])

c. Both of the above

d. None of the above

[showhide type=”links92″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. Both of the above [/showhide]

Q93. Display marks of Karan and Rounaq in Maths and Science

a. print(DF.loc[‘Science’ : ‘Maths’, ‘Karan’ : ‘Rounaq’])

b. print(DF.loc[‘Science’ : ‘Maths’, [‘Karan’ : ‘Rounaq’]])

c. Both of the above

d. None of the above

[showhide type=”links93″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. print(DF.loc[‘Science’ : ‘Maths’, ‘Karan’ : ‘Rounaq’]) [/showhide]

Q94. Display marks of all students in Maths and Science.

a. print(DF.loc[‘Maths’ : ‘Science’])

b. print(DF.loc[‘Science’ : ‘Maths’])

c. Both of the above

d. None of the above

[showhide type=”links94″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. print(DF.loc[‘Science’ : ‘Maths’]) [/showhide]

Q95. Write a statement to check that in which subject kiran scored more than 90.

a. DF.loc[ : , ‘Kiran’] >= 90

b. DF.loc[:, ‘Kiran’] < 90

c. DF.loc[: , ‘Kiran’] > 90

d. None of the above

[showhide type=”links95″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.loc[: , ‘Kiran’] > 90 [/showhide]

Python DataFrame
Python DataFrame MCQ

Q96. Write a statement to rename the subject ‘Maths’ to ‘Mathematics’

a. DF.ren({“Maths” : “Mathematics”})

b. DF.Rename({“Maths”:”Mathematics”})

c. DF.rename({“Maths”:”Mathematics”})

d. DF.replace({“Maths”:”Mathematics”})

[showhide type=”links96″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. c. DF.rename({“Maths”:”Mathematics”}) [/showhide]

Q97. Write a statement to remove column labelled as ‘Harry’

a. print(DF.drop(‘Harry’, axis = 0))

b. print(DF.drop(‘Harry’, axis = 1))

c. Both of the above

d. None of the above

[showhide type=”links97″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. print(DF.drop(‘Harry’, axis = 1)) [/showhide]

Q98. Write a statement to increase five marks of all students in all subjects.

a. DF[ : ] = DF[ : ]+5

b. DF[ : ] = DF[ : ]+[5]

c. Both of the above

d. None of the above

[showhide type=”links98″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF[ : ] = DF[ : ]+5 [/showhide]

Q99. Write a statement to add new column labelled ‘Ruby’ with values 85, 75, 79.

a. DF[Ruby]=[85, 75, 79]

b. DF[‘Ruby’] = [85, 75, 79]

c. DF[‘Ruby’=[85,75,79]]

d. None of the above

[showhide type=”links99″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. b. DF[‘Ruby’] = [85, 75, 79] [/showhide]

Q100. Write a statement to increase marks of ‘Anuj’ in ‘Maths’ Subject by 10.

a. DF.loc[‘Maths’, ‘Anuj’]=DF.loc[‘Maths’, ‘Anuj’]+10

b. DF.loc[‘Anuj’, ‘Maths’]=DF.loc[‘Maths’, ‘Anuj’]+10

c. DF.loc[‘Anuj’, ‘Maths’]=DF.loc[‘Anuj’, ‘Maths’]+10

d. None of the above

[showhide type=”links100″ more_text=”Show Answer” less_text=”Hide Answer”] Ans. a. DF.loc[‘Maths’, ‘Anuj’]=DF.loc[‘Maths’, ‘Anuj’]+10 [/showhide]

Python dataframe MCQ Class 12


Disclaimer : I tried to give you the correct ” Python dataframe MCQ Class 12 , but if you feel that there is/are mistakes in ” Python dataframe MCQ Class 12 ” given above, you can directly contact me at csiplearninghub@gmail.com. Book and Study material available on CBSE official website are used as a reference to create above “ Python dataframe MCQ Class 12 “.

Python dataframe MCQ Class 12

Python DataFrame
Python DataFrame MCQ

Python dataframe MCQ Class 12

Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

120 Practice Questions of Computer Network in Python

70 Practice Questions on if-else

40 Practice Questions on Data Structure

Computer Science Syllabus 2021-2022.

Informatics Practices Syllabus 2021-2022

Class 12 Computer Science Chapter wise MCQ

2 thoughts on “100 Important Python dataframe MCQ Class 12 IP”

Leave a Comment