Pandas MCQ Questions with
Answers
Q11. A __________ is a collection of data
values and operations that can be
applied to that data.
a. Data Structure
b. Data Frame
c. Table
d. None of the above
Show Answer
Q12. A _______________ is a one-
dimensional array.
a. Data Frame
b. Series
c. Both of the above
d. None of the above
Show Answer
Q13. Which of the following statement
is wrong?
a. We can create Series from Dictionary in Python.
b. Keys of dictionary become index of the series.
c. Order of indexes created from Keys may not be in the
same order as typed in dictionary.
d. All are correct
Show Answer
Q14. A Series by default have numeric
data labels starting from ______________.
a. 3
b. 2
c. 1
d. 0
Show Answer
Q15. The data label associated with a
particular value of Series is called
its ______________
a. Data value
b. Index
c. Value
d. None of the above
Show Answer
Q16. Which of the following module is
to be imported to create Series?
a. NumPy
b. Pandas
c. Matplotlib
d. None of the above
Show Answer
Q17. Which of the following
function/method help to create Series?
a. series( )
b. Series( )
c. createSeries( )
d. None of the above
Show Answer
Q18. Write the output of the following :
>>> import pandas as pd
>>> series1 = pd.Series([10,20,30])
>>> print(series1)
a.
Output:
0 10
1 20
2 30
dtype: int64
b.
Output:
10
20
30
dtype: int64
c.
Output:
dtype: int64
d. None of the above
Show Answer
Q19. When you print/display any series
then the left most column is showing
_________ value.
a. Index
b. Data
c. Value
d. None of the above
Show Answer
Q20. How many values will be there in
array1, if given code is not returning
any error?
>>> series4 = pd.Series(array1, index = [“Jan”, “Feb”,
“Mar”, “Apr”])
a. 1
b. 2
c. 3
d. 4
Show Answer
Q21. Which of the following statement
will create an empty series named
“S1”?
a. S1 = pd.Series(None)
b. S1 = pd.Series( )
c. Both of the above
d. None of the above
Show Answer
Q22. How many elements will be there
in the series named “S1”?
>>> S1 = pd.Series(range(5))
>>> print(S1)
a. 5
b. 4
c. 6
d. None of the above
Show Answer
Q23. When we create a series from
dictionary then the keys of dictionary
become ________________
a. Index of the series
b. Value of the series
c. Caption of the series
d. None of the series
Show Answer
Q24. Write the output of the following :
>>> S1=pd.Series(14, index = ['a', 'b', 'c'])
>>> print(S1)
a.
a 14
b 14
c 14
dtype: int64
b.
a 14
dtype: int64
c. Error
d. None of the above
Show Answer
Q25. Write the output of the following:
>>> S1=pd.Series(14, 7, index = ['a', 'b', 'c'])
>>> print(S1)
a.
a 14
b7
c7
dtype: int64
b.
a 14
b7
dtype: int64
c. Error
d. None of the above
Show Answer
Q26. Write the output of the following :
>>> S1=pd.Series([14, 7, 9] ,index = range(1, 8, 3))
>>> print(S1)
a.
14 1
7 4
9 7
dtype: int64
b.
1 14
47
79
dtype: int64
c. Error
d. None of the above
Show Answer
Q27. Which of the following code will
generate the following output?
Jan 31
Feb 28
Mar 31
dtype: int64
a.
import pandas as pd
S1 = pd.Series(data = [31,28,31], index=["Jan","Feb","Mar"])
print(S1)
b.
import pandas as pd
S1 = pd.Series([31,28,31], index=["Jan","Feb","Mar"])
print(S1)
c. Both of the above
d. None of the above
Show Answer
Q28. Write the output of the following:
import pandas as pd
S1 = pd.Series(data = range(31, 2, -6), index = [x for x in
"aeiou" ])
print(S1)
a.
a 31
e 25
i 19
o 13
u7
dtype: int64
b.
a 31
e 25
i 19
o 13
dtype: int64
c. Error
d. None of the above
Show Answer
Q29. What type of error is returned by
following code?
import pandas as pd
S1 = pd.Series(data = (31, 2, -6), index = [7, 9, 3, 2])
print(S1)
a. SyntaxError
b. IndexError
c. ValueError
d. None of the above
Show Answer
Q30. Write the output of the following :
import pandas as pd
S1 = pd.Series(data = 2*(31, 2, -6))
print(S1)
a.
0 31
12
2 -6
dtype: int64
b.
0 31
12
2 -6
3 31
42
dtype: int64
c.
0 31
12
2 -6
3 31
dtype: int64
d.
0 31
12
2 -6
3 31
42
5 -6
dtype: int64
Show Answer
Q31. We can imagine a Pandas Series
as a ______________ in a spreadsheet
a. Column
b. Cell
c. Table
d. None of the above
Show Answer
Q32. We can assign user-defined labels
to the index of the series?(T/F)
a. True
b. False
Show Answer
Q33. 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
Show Answer
Q34. 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
Show Answer
Q35. 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
Show Answer
Q36. Which attribute is used to give
user defined labels in Series?
a. index
b. data
c. values
d. None of the above
Show Answer
Q37. 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. All of the above
Show Answer
Q38. 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 of the above
d. print(S1.India)
Show Answer
Q39. 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
Show Answer
Q40. 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
Show Answer
Q41. 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( ))
Show Answer
Q42. 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
Show Answer
Q43. 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
Show Answer
Q44. Which of the following
property/attribute assign name to the
Series?
a. name
b. index.name
c. size
d. Series.name
Show Answer
Q45. S1.values will return all the values
of Series ‘S1’ in _________
a. Tuple
b. Dictionary
c. List
d. String
Show Answer
Q46. 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
Q47. Which of the following attributes
returns True if there is no value in
Series?
a. index
b. size
c. empty
d. values
Show Answer
Q48. Which of the following attributes
returns all the values of Series?
a. size
b. index
c. name
d. values
Show Answer
Q49. 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
Q50. 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
Show Answer
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q51. 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
Q52. 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
Show Answer
Q53. Which of the following returns
number of non-NaN values of Series?
a. count
b. size
c. index
d. values
Show Answer
Q54. 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
Show Answer
Q55. We can perform _____________ on
two series in Pandas.
a. Addition
b. Subtraction
c. Multiplication
d. All of the above
Show Answer
Q56. Which of the following method is
used to add two series?
a. sum( )
b. addition( )
c. add( )
d. None of the above
Show Answer
Q57. 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
Q58. Which of the following fills the
missing values in Series?
a. fill value
b. fill-value
c. fill_value
d. fill_value( )
Show Answer
Q59. 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
Q60. 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
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q61. 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
Q62. 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
Q63. 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)
Show Answer
Q64. 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
Q65. 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
Pandas MCQ Questions with
Answers
Q66. 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
Q67. We can have duplicate indexes in
Series?(T/F)
a. True
b. False
Show Answer
Q68. 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
Q69. 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
Q70. 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
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q71. Python libraries contain a
collection of built-in _____________
a. Data
b. Modules
c. Packages
d. Data Structure
Show Answer
Q72. What is “Pandas” in the following
statement?
import pandas as pd
a. Library
b. Module
c. Package
d. Function
Show Answer
Q73. Which of the following library help
to visualize data?
a. Pandas
b. Numpy
c. Matplotlib
d. Random
Show Answer
Q74. Which of the following is a high
level data manipulation tool used for
analyzing data.?
a. Nump
b. Pandas
c. Matplotlib
d. Math
Show Answer
Q75. Pandas is the ____ library.
a. Freeware
b. Proprietary
c. Open source
d. End source
Show Answer
Pandas MCQ Questions with
Answers
Q76. Pandas Series is size __________
and value ___________
a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable
Show Answer
Q77. Pandas DataFrame is size ________
and value ________
a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable
Show Answer
Q78. ‘data’ in the following code could
be _____________
S1 = pd.Series(data)
a. Python sequence
b. Scalar value
c. Python dictionary
d. All of the above
Show Answer
Q79. Choose the correct statement :
Statement1 : A Numpy array requires homogeneous data.
Statement2 : Pandas DataFrame can have heterogeneous data.
a. Statement1 is correct
b. Statement2 is correct
c. Both the statements are correct
d. Both the statements are wrong
Show Answer
Q80. __________ is used when data is in
Tabular Format.
a. Pandas
b. Numpy
c. Both of the above
d. None of the above
Show Answer
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q81. Amit is working in an IT company.
His boss asked him to prepare a chart
in python. He is confused that which
library will support plotting graph and
data visualization in python. Help him
to find the library
a. Pandas
b. Matplotlib
c. Numpy
d. Math
Show Answer
Q82. By using Matplotlib, we can
generate ____
a. Histograms
b. Bar charts
c. Scatterplots
d. All of the above
Show Answer
Q83. Installing Pandas is very similar to
installing ____________
a. Microsoft Word
b. Numpy
c. Python
d. MySQL
Show Answer
Q84. NumPy and Pandas can be
installed only when ________ is already
installed on that system.
a. Matplotlib
b. Python
c. Excel
d. Word
Show Answer
Q85. By default Series have _______
data labels starting from ___.
a. character, ‘a’
b. numeric, one
c. numeric, zero
d. character, zero
Show Answer
Q86. Write a statement to import
pandas with alias name ‘pds’
a. import pandas as pds
b. Import pandas as pds
c. import panda as pds
d. import Pandas as pds
Show Answer
Q87. What is the index value of “Ravi”
in the following Series?
import pandas as pd
S1 = pd.Series["Ram", "Raju", "Ravi", "Ramesh", "Rishabh"]
a. 0
b. 1
c. 2
d. 3
Show Answer
Q88. An output of series ‘S1’ is shown
below, are the data values in ‘S1 and _
are the data labels in ‘S1’.
Output:
Feb 2
Mar 3
Apr 4
dtype: int64
a. Month name, Numbers
b. Numbers, Month name
c. Month name, Month name
d. Numbers, Numbers
Show Answer
Q89. What is the data type of given
series ‘S1’?
import pandas as pd
S1=pd.Series('a', index=(2.0, 3.0, 4.0, 5.0))
print(S1)
a. float64
b. int64
c. object
d. string
Show Answer
Q90. How many elements will be there
in given series ‘S1’?
import pandas as pd
S1=pd.Series('python practice')
print(S1)
a. 0
b. 1
c. 2
d. 15
Show Answer
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q91. Two common ways for accessing
the elements of a series are _________
and _______
a. Indexing, Concatenation
b. Labelled Indexing, Positional Indexing
c. Indexing, Slicing
d. Slicing, Cutting
Show Answer
Q92. How many times value ’10’ will be
displayed in the given series ‘S1’?
import pandas as pd
S1=pd.Series(10, index = range(1, 10, 3))
print(S1)
a. 1
b. 3
c. 5
d. 4
Show Answer
Q93. Which of the following statement
is correct to add NaN value in series?
a. S1=pd.Series([10, np.NaN,11])
b. S1=pd.Series([10, None, 11])
c. Both of the above
d. None of the above
Show Answer
Q94. Which of the following is
parameter of Series( ) function?
a. data
b. index
c. dtype
d. All of the above
Show Answer
Q95. What is the data type of series
‘S1’ given below ?
S1=pd.Series([11, 12.5, “ok”])
a. int64
b. float64
c. object
d. object64
Show Answer
Q96. Which of the following attribute of
Series is used to set the name of Series
object?
a. size
b. name
c. index.name
d. values
Show Answer
Q97. Which of the following attribute is
used to check NaN value in Series?
a. hasNans
b. hasnans
c. Hasnans
d. HasNans
Show Answer
Q98. Which of the following attribute of
Series returns the tuple?
a. size
b. shape
c. values
d. index
Show Answer
Q99. What type of error is returned,
when the length of index and the
length of data in Series() function is not
same?
a. Key Error
b. Value Error
c. Syntax Error
d. Name Error
Show Answer
Q100. Write a statement to display
12.5 as output using positional
indexing.
import pandas as pd
S1=pd.Series([11, 12.5, None, 6], index=["J","F","M","A"])
a. print(S1[1])
b. print(S1[“J”])
c. print(S1[0])
d. print(S1[“F”])
Show Answer
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q101. Can a Series have duplicate
index value?
a. Yes
b. No
c. Yes, Only series with integer values
d. Yes, Only series with character values
Show Answer
Q102. Rosy wants to display the series
‘S1’ in reverse order. Help her to find
the correct code.
a. >>> S1[ : : 1]
b. >>> S1[ : : -1]
c. >>> S1[ -1 : :]
d. >>> S1[ : 1 1]
Show Answer
Q103. Number of students in each
section of class 9th is stored in series
‘S1’. Write a statement to change the
value of section ‘A’ and ‘B’ to 50.
A 41
B 44
C 40
D 42
E 47
a. S1[ : 2] = 50
b. S1[0 : 2] = 50
c. Both of the above
d. None of the above
Show Answer
Q104. head( ) function return
__________ n rows and tail function
return _____________ n rows from a
pandas object.
a. last, first
b. first, second
c. last, seven
d. first, last
Show Answer
Q105. Series ‘S1’ has five values with
index value (0, 1, 2, 3, 4) and series
‘S2’ has five values with index (2, 3, 4,
5, 6). What will be the total number of
values in ‘S3’ if S3 = S1 + S2
a. 5
b. 6
c. 7
d. 8
Show Answer
Q106. Raman performed addition of
series ‘S1’ and ‘S2’ and store the result
in series ‘S3’. Both the series ‘S1’ and
‘S2’ have five mismatching index
value. How many NaN will be there in
‘S3’?
a. 2
b. 3
c. 4
d. 5
Show Answer
Q107. Which of the following statement
return Boolean result?
import pandas as pd
S1=pd.Series([11, 12, 5, 6,9])
print(S1) #Statement 1
print(S1>7) #Statement 2
print(S1[S1>7]) #Statement 3
a. Statement 1
b. Statement 2
c. Statement 3
d. None of the above
Show Answer
Q108. Which of the following statement
return Filtered result?
import pandas as pd
S1=pd.Series([11, 12, 5, 6,9])
print(S1) #Statement 1
print(S1>7) #Statement 2
print(S1[S1>7]) #Statement 3
a. Statement 1
b. Statement 2
c. Statement 3
d. None of the above
Show Answer
Q109. Amit is working in an IT firm as
Data Manager. He stored the salary of
all employees in Series named
“Empser”. His Boss asked him to filter
the employees whose salary is more
than 20000. Help him to find the
correct code. Sample of data stored is
shown below.
0 25000
1 20000
2 21000
3 30000
a. print(Seremp > 20000)
b. print(Seremp (Seremp> 20000) )
c. print(Seremp [Seremp > 20000] )
d. print[Seremp> 20000]
Show Answer
Q110. __________ function is used to
sort a Series object on the basis of
values.
a. sort.values( )
b. sort_values( )
c. sort_value( )
d. sort_Values
Show Answer
Pandas MCQ Questions with
Answers
Click here to check your performance on Pandas MCQ Questions
Pandas MCQ Questions with
Answers
Q111. Anshuman wants to create a
series named ‘S1’. He has written the
following codes. His friend Shubham
checked the code and said that one of
the code given below is not working. As
a friend of Anshuman, help him to find
the incorrect code.
a. S1=pd.Series(data=[11, 12, 5, 6,9],index=[1,2,3,4,5])
b. S1=pd.Series([11, 12, 5, 6,9],index=[1,2,3,4,5])
c. S1=pd.Series([11, 12, 5, 6,9],[1,2,3,4,5])
d. S1=pd.Series(data=[11, 12, 5, 6,9], [1,2,3,4,5])
Show Answer
Q112. Sonal is a class XII student. She
is learning “Series” in Python. She is
confused in “parameter of Series( )
function”. Help her to find the incorrect
parameter.
a. data
b. index
c. number
d. dtype
Show Answer
Q113. Roshan has written few points
about iloc( ) function of Series in
Python. His friend Suman told that one
of the written statement is not correct.
Help him to find the incorrect
statement.
a. In iloc( ) method, we have to pass an integer index.
b. This method include the last element of the range passed.
c. S1.iloc[3] will display fourth value of Series ‘S1’
d. S1.iloc[:3] will display first three values of Series ‘S1’
Show Answer
Q114. print(S1[-1]) will
return ___________ #’S1′ is a series
a. last element of series ‘S1’
b. first element of series ‘S1’
c. Key Error
d. all elements of series ‘S1’
Show Answer
Q115. >>> S1[1:3] = 50 will update
the value of ___________ elements
a. 1
b. 2
c. 3
d. 4
Show Answer
Q116. ____________ statement will
assigns a name to the Series ‘S1’.
a. >>> S1.name = “Empl”
b. >>> S1_name = “Empl”
c. >>> S1[name] = “Empl”
d. >>> S1.indexname = “Empl”
Show Answer
Q117. Write the output of the following:
import pandas as pd
S1=pd.Series(data=[11, 12, None, 6,9,7],index=[1,12,3,4,2,4])
print(S1.count())
a. 4
b. 6
c. 5
d. Error
Show Answer
Q118. While performing mathematical
operations on series, index matching is
implemented and all missing values are
filled in with ___________ by default
a. NaN
b. None
c. 0
d. 1
Show Answer
Q119. Mr. Kumar is working in an IT
company. He stored the salaries of all
the employees of January month in
Series ‘Jan_Sal’ and salaries of February
month in Series ‘Feb_Sal’. Now he
wants to add the salaries of both
months. He has written the following
statement. Identify the correct one.
a. print(Feb_Sal + Jan_Sal)
b. print(Feb_Sal_add_Jan_Sal)
c. print(Feb_Sal plus Jan_Sal)
d. None of the above
Show Answer
Q120. Which of the following method is
used to subtract the two series?
a. subtract( )
b. subtraction( )
c. diff( )
d. sub( )
Show Answer