Python dataframe MCQ Class 12
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
Q2. A _______________ is a two-dimensional labelled data structure .
a. DataFrame
b. Series
c. List
d. None of the above
Q3. _____________ data Structure has both a row and column index.
a. List
b. Series
c. DataFrame
d. None of the above
Q4. Which library is to be imported for creating DataFrame?
a. Python
b. DataFrame
c. Pandas
d. Random
Q5. Which of the following function is used to create DataFrame?
a. DataFrame( )
b. NewFrame( )
c. CreateDataFrame( )
d. None of the Above
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
Q7. We can create DataFrame from _____
a. Numpy arrays
b. List of Dictionaries
c. Dictionary of Lists
d. All of the above
Q8. Which of the following is used to give user defined column index in DataFrame?
a. index
b. column
c. columns
d. colindex
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
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
Python dataframe MCQ Class 12
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
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
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
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
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
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
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
Q18. We can create a DataFrame using a single series. (T/F)
a. True
b. False
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
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
Q22. We can add a new row to a DataFrame using the _____________ method
a. rloc[ ]
b. iloc[ ]
c. loc[ ]
d. None of the above
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
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
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
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
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
Q28. Which method is used to delete row or column in DataFrame?
a. delete( )
b. del( )
c. drop( )
d. None of the above
Q29. To delete a row, the parameter axis of function drop( ) is assigned the value ______________
a. 0
b. 1
c. 2
d. 3
Q30. To delete a column, the parameter axis of function drop( ) is assigned the value _____________
a. 0
b. 1
c. 2
d. 3
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
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
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)
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
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
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
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
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
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
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
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
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
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
Q45. The following statement will display ________ rows of DataFrame ‘DF’
print(df.loc[[True, False,True]])
a. 1
b. 2
c. 3
d. 4
Python dataframe MCQ Class 12
Q46. We can use the ______ method to merge two DataFrames
a. merge( )
b. join( )
c. append( )
d. drop( )
Q47. We can merge/join only those DataFrames which have same number of columns.(T/F)
a. True
b. False
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
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
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
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
Q53. Which of the following attribute of DataFrame is used to display row labels?
a. columns
b. index
c. dtypes
d. values
Q54. Which of the following attribute of DataFrame is used to display column labels?
a. columns
b. index
c. dtypes
d. values
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
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
Q57. Which of the following attribute of DataFrame display the dimension of DataFrame
a. shape
b. size
c. dimension
d. values
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
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
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
Q62. Following statement will display ___________ rows from DataFrame ‘DF1’.
>>> DF1.head()
a. All
b. 2
c. 3
d. 5
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
Q64. Which property of dataframe is used to check that dataframe is empty or not?
a. isempty
b. IsEmpty
c. empty
d. Empty
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
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
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
Q68. Parameters of read_csv( ) function is _____
a. sep
b. header
c. Both of the above
d. None of the above
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( )
Q70. The default value for sep parameter is _________
a. comma
b. semicolon
c. space
d. None of the above
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
Q72. Write statement to display the column labels of DataFrame ‘DF’
a. DF.Column
b. DF.column
c. DF.columns
d. DF.Columns
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
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
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
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
Q77. Write statement to transpose dataframe DF.
a. DF.T
b. DF.transpose
c. DF.t
d. DF.T( )
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
Q79. Write statement to display the shape of dataframe ‘DF’.
a. DF.Shape
b. DF.shape
c. DF.shapes
d. DF.Shapes
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
Python dataframe MCQ Class 12
Click here to check your performance in Python DataFrame
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
2014 | 2015 | 2016 | 2017 | |
Madhu | 100.5 | 12000 | 20000 | 50000 |
Kusum | 150.8 | 18000 | 50000 | 60000 |
Kinshuk | 200.9 | 22000 | 70000 | 70000 |
Ankit | 30000 | 30000 | 10000 | 80000 |
Shruti | 40000 | 45000 | 125000 | 90000 |
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
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
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
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
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
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
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
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))
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
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)
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.
Harry | Kiran | Anuj | Karan | Rounaq | |
Science | 85 | 82 | 65 | 60 | 90 |
Maths | 90 | 95 | 85 | 80 | 75 |
English | 80 | 85 | 75 | 70 | 60 |
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
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
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
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
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
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”})
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
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
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
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
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 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
its amazing very much helpful fpor practicing
Thankyou so much.