40+ most important Pandas mcq questions and answers

Pandas is one of the most popular python library. Pandas is highly used for various data engineering tasks. Following are the python pandas mcq questions to help you better understand the pandas module. These Python Pandas multiple choice questions are both theory based and practical based so you will gain a significant amount of Hands-on knowledge from the given pandas exercises mcqs. We are also trying to put Pandas mcq pdf download link to get pandas mcq questions for free.

Python Pandas mcq questions with answers

Q.31. We can imagine a Pandas Series as a ______________ in a spreadsheet

a. Column
b. Cell
c. Table
d. None of the above

Answer- a. Column

Q.32. We can assign user-defined labels to the index of the series?(T/F)
a. True
b. False
Answer- a. True

Q.33. Write the output of the following :
import pandas as pd
series2 = pd.Series([“Kavi”,”Shyam”,”Ravi”], index=[3,5,1])
print(series2 > “S”)

a.
3 False
5 False
1 False
dtype: bool
b.
3 False
5 True
1 False
dtype: bool
c.
3 True
5 True
1 True
dtype: bool
d. None of the above

Answer –

b.
3 False
5 True
1 False
dtype: bool

Q.34. Which of the following statement is correct for importing pandas in python?
a. import pandas
b. import pandas as pd
c. import pandas as pds
d. All of the above

d. All of the above

Q.35. What type of error is returned by following statement?
import pandas as pnd
pnd.Series([1,2,3,4], index = [‘a’,’b’,’c’])

a. SyntaxError
b. IndexError
c. ValueError
d. None of the above

a. SyntaxError

Q.36. Which attribute is used to give user defined labels in Series?
a. index
b. data
c. values
d. None of the above

a. index

Q.37. Fill in the blank to get the ouput as 3
import pandas as pnd
S1=pnd.Series([1,2,3,4], index = [‘a’,’b’,’c’,’d’])
print(S1[_])

a. ‘c’
b. 2
c. c
d. Both a and b

a. ‘c’

Q.38. Write the statement to get NewDelhi as output using positional index.
import pandas as pd
S1 = pd.Series([‘NewDelhi’, ‘WashingtonDC’, ‘London’, ‘Paris’],
index=[‘India’, ‘USA’, ‘UK’, ‘France’])

a. print(S1[0])
b. print(S1[‘India’])
c. Both a and b
d. print(S1.India)

c. Both a and b

Q.39. We can access elements in Series by using ________ index and ____________index.
a. Numeric, labelled
b. Positional, Naming
c. Positional, labelled
d. None of the above

c. Positional, labelled

Q.40. Write the output of the following :

import pandas as pd
S1 = pd.Series([‘NewDelhi’, ‘WashingtonDC’, ‘London’, ‘Paris’],
index=[‘India’, ‘USA’, ‘UK’, ‘France’])
print(S1[‘India’, ‘UK’])

a.
India NewDelhi
UK London
dtype: object
b.
India NewDelhi
UK Washington
dtype: object
c. Error
d. None of the above

c. Error

Pandas mcq questions and answers

Q.41. Which of the following statement will print Series ‘S1’ in reverse order?
a. print(S1[: : 1]
b. print(S1[: : -1]
c. print(S1[-1: : 1]
d. print(S1.reverse( ))

b. print(S1[: : -1])

Q.42. How many values will be modified by last statement of given code ?
import pandas as pd
S1 = pd.Series([‘NewDelhi’, ‘WashingtonDC’, ‘London’, ‘Paris’],
index=[‘A’, ‘B’, ‘C’, ‘D’])
S1[‘A’ : ‘C’] = ‘ND’

a. 1
b. 2
c. 3
d. 4

b. 2

Q.43. How many values will be modified by last statement of given code ?
import pandas as pd
S1 = pd.Series([‘NewDelhi’, ‘WashingtonDC’, ‘London’, ‘Paris’],
index=[‘A’, ‘B’, ‘C’, ‘D’])
S1[1 : 3] = ‘ND’

a. 1
b. 2
c. 3
d. 4
b. 2

b. 2

Q.44. Which of the following property/attribute assign name to the Series?
a. name
b. index.name
c. size
d. Series.name

Show Answer

Q.45. S1.values will return all the values of Series ‘S1’ in _________
a. Tuple
b. Dictionary
c. List
d. String
er

Show Answer

Q.46. Which of the following property/attribute return total number of values in Series ‘S1’?
a. size
b. values
c. index
d. None of the above

Show Answer

Q.47. Which of the following attributes returns True if there is no value in Series?
a. index
b. size
c. empty
d. values
er

Show Answer

Q.48. Which of the following attributes returns all the values of Series?
a. size
b. index
c. name
d. values
er

Show Answer

Q.49. Write the output of the following code:
import pandas as pd
S1=pd.Series()
print(pd.Series().empty)

a. True
b. False
c. Error
d. None of the above

Show Answer

Q.50. Write the output of the following code :
import pandas as pd
S1=pd.Series([1,2,3,4])
S2=pd.Series([7,8])
S3=S1+S2
print(S3.size)

a. 2
b. 4
c. 6
d. Error
wer

Show Answer

Python Pandas multiple choice questions with answers

Q.51. Which of the following statement shows first five values of Series ‘S1’?
a. S1.head( )
b. S1.head( 5 )
c. Both of the above
d. None of the above

Show Answer

Q.52. Write the output of the following :
import pandas as pd
S1=pd.Series([1,2,3,4])
S2=pd.Series([7,8])
print((S1+S2).count())

a. 6
b. 4
c. 2
d. 0
Answer

Show Answer

Q.53. Which of the following returns number of non-NaN values of Series?
a. count
b. size
c. index
d. values
Show Answer

Show Answer

Q.54. Write the output of the following :
import pandas as pd
S1=pd.Series([1,2,3,4])
S2=pd.Series([7,8,9,10])
S2.index=[‘a’,’b’,’c’,’d’]
print((S1+S2).count())

a. 8
b. 4
c. 0
d. 6
Answer

Show Answer

Q.55. We can perform _____________ on two series in Pandas.
a. Addition
b. Subtraction
c. Multiplication
d. All of the above

Show Answer

Q.56. Which of the following method is used to add two series?
a. sum( )
b. addition( )
c. add( )
d. None of the above

Show Answer

Q.57. Which of the following statement will display the difference of two Series ‘A’ and ‘B’?
a. >>>A – B
b. >>>A.sub(B)
c. Both of the above
d. None of the above

Show Answer

Q.58. Which of the following fills the missing values in Series?
a. fill value
b. fill-value
c. fill_value
d. fill_value( )

Show Answer

Q.59. Which of the following function is used for basic mathematical operations in Series?
a. add( )
b. mul( )
c. div( )
d. All of the above

Show Answer

Q.60. Which of the following statement is replacing missing values of Series A and Series B by 100 .
a. >>> A.add(B, fill_value = 100)
b. >>>A.add(B, fill_value : 100)
c. >>> A.add(B, fill-value = 100)
d. >>> A.add(B, fill-value : 100)

Show Answer

>>> A.add(B, fill_value = 100)

Python Pandas mcqs

Q.61. Mathematical Operations on two Series object is done by matching ____________
a. indexes
b. values
c. Both of the above
d. None of the above

Show Answer

Q.62. Which of the following statement will display values more than 40 from Series ‘S1’?
a. >>>S1
b. >>> S1 > 40
c. >>>S1[S1 > 40]
d. None of the above

Show Answer

Q.63. Which of the following statement will return 10 values from the bottom/end of the Series ‘S1’?
a. S1.tail( )
b. S1.tail(10)
c. S1.head(10)
d. S1(10)
er

Show Answer

Q.64. Which of the following are valid operations on Series ‘S1’?
a. >>> S1 + 2
b. >>> S1 ** 2
c. >>> S1 * 2
d. All of the above

Show Answer

Q.65. When an operation is carried out on every value of Series object is called _____
a. Scalar Operation
b. Vector Operation
c. Both of the above
d. None of the above

Show Answer

Q.66. Which of the following statement will modify the first three values of Series ‘S1’?
a. S1[0, 1, 2] = 100
b. S1[0 : 3] = 100
c. S1[ : 3] = 100
d. All of the above

Show Answer

Q.67. We can have duplicate indexes in Series?(T/F)
a. True
b. False
Show Answer

Show Answer

Q.68. What is the index value of 31 in given Series ‘S1’?
import pandas as pd
S1=pd.Series([1,2,31,4], index = [‘a’,’b’,’c’,’d’])

a. ‘c’
b. 2
c. Both of the above
d. None of the above

Show Answer

Q.69. S2 is ____________ in given code ?
S2 = S1[2 : 5] #S1 is a Series object

a. List
b. Tuple
c. Series
d. None of the above

Show Answer

Q.70. Following two statements will provide the same output.(T/F)
>>>L1 * 2 #L1 is a list
>>>S1 * 2 #S1 is a Series

a. True
b. False
Show Answer

Show Answer

Leave a Comment