0% found this document useful (1 vote)
248 views

Pandas Series Practice Questions

This document contains 69 multiple choice questions related to Python Pandas. The questions cover key Pandas concepts like Series, DataFrames, indexing, mathematical and logical operations on Series objects. Some questions test understanding of Pandas functions and methods like head(), tail(), count(), fillna() etc. Overall, the questions assess a tester's knowledge of the essentials of working with Series and DataFrames in Pandas.

Uploaded by

Swayam Katti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
248 views

Pandas Series Practice Questions

This document contains 69 multiple choice questions related to Python Pandas. The questions cover key Pandas concepts like Series, DataFrames, indexing, mathematical and logical operations on Series objects. Some questions test understanding of Pandas functions and methods like head(), tail(), count(), fillna() etc. Overall, the questions assess a tester's knowledge of the essentials of working with Series and DataFrames in Pandas.

Uploaded by

Swayam Katti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Q1.

Which of the following are


modules/libraries in Python?

a. NumPy
b. Pandas
c. Matplotlib
d. All of the above

Q2. NumPy stands for ____


a. Number Python
b. Numerical Python
c. Numbers in Python
d. None of the above

Q3. Which of the following libraries allows to


manipulate, transform and visualize data easily
and efficiently.

a. Pandas
b. NumPy
c. Matplotlib
d. All of the above

Q4. PANDAS stands for _____________


a. Panel Data Analysis
b. Panel Data analyst
c. Panel Data
d. Panel Dashboard

Q5. __________ is an important library used for


analyzing data.
a. Math
b. Random
c. Pandas
d. None of the above

Q6.Important data structure of pandas


is/are ___________
a. Series
b. Data Frame
c. Both of the above
d. None of the above

Q7. Which of the following library in Python is


used for plotting graphs and visualization.

a. Pandas
b. NumPy
c. Matplotlib
d. None of the above

Q8. Pandas Series can


have _________________ data types
a. float
b. integer
c. String
d. All of the above

Q9. _________ is used when data is in Tabular


Format.
a. NumPy
b. Pandas
c. Matplotlib
d. All of the above

Q10. Which of the following command is used


to install pandas?

a. pip install pandas


b. install pandas
c. pip pandas
d. None of the above
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

Ans. a. Data Structure


Q12. A _______________ is a one-dimensional
array.
a. Data Frame
b. Series
c. Both of the above
d. None of the above

Ans. b. Series
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

Q14. A Series by default have numeric data


labels starting from ______________.
a. 3
b. 2
c. 1
d. 0

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

Q16. Which of the following module is to be


imported to create Series?

a. NumPy
b. Pandas
c. Matplotlib
d. None of the above

Q17. Which of the following function/method


help to create Series?

a. series( )
b. Series( )
c. createSeries( )
d. None of the above

Q18. Write the output of the following :

>>> import pandas as pd 

>>> series1 = pd.Series([10,20,30])

>>> print(series1)

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
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”])

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

Q22. How many elements will be there in the


series named “S1”?

>>> S1 = pd.Series(range(5))

>>> print(S1)
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

Q24. Write the output of the following :

>>> S1=pd.Series(14, index = ['a', 'b', 'c'])


>>> print(S1)

Q25. Write the output of the following:

>>> S1=pd.Series(14, 7, index = ['a', 'b', 'c'])


>>> print(S1)

Q26. Write the output of the following :

>>> S1=pd.Series([14, 7, 9] ,index = range(1, 8,


3))
>>> print(S1)
Q27. Write the code to generate the following
output?

Jan 31
Feb 28
Mar 31
dtype: int64

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)

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)
Q30. Write the output of the following :

import pandas as pd
S1 = pd.Series(data = 2*(31, 2, -6))
print(S1)

Q31. We can imagine a Pandas Series as


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

Q32. We can assign user-defined labels to the


index of the series?(T/F)

a. True
b. False

Q33. Write the output of the following :

import pandas as pd
series2 = pd.Series([“Kavi”,”Shyam”,”Ravi”],
index=[3,5,1])
print(series2 > “S”)
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

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

Q36. Which attribute is used to give user


defined labels in Series?

a. index
b. data
c. values
d. None of the above

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[___________])

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'])
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

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'])

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( ))

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'
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'

Q44. Which of the following property/attribute


assign name to the Series?

a. name
b. index.name
c. size
d. Series.name

Q45. S1.values will return all the values of


Series ‘S1’ in _________
a. Tuple
b. Dictionary
c. List
d. string

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

Q47. Which of the following attributes returns


True if there is no value in Series?

a. index
b. size
c. empty
d. values

Q48. Which of the following attributes returns


all the values of Series?

a. size
b. index
c. name
d. values

Q49. Write the output of the following code:

import pandas as pd
S1=pd.Series()
print(pd.Series().empty)

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)

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
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())

Q53. Which of the following returns number of


non-NaN values of Series?

a. count
b. size
c. index
d. values

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())
Q55. We can perform _____________ on two
series in Pandas.

a. Addition
b. Subtraction
c. Multiplication
d. All of the above

Q56. Which of the following method is used to


add two series?

a. sum( )
b. addition( )
c. add( )
d. None of the above

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
Q58. Which of the following fills the missing
values in Series?

a. fill value
b. fill-value
c. fill_value
d. fill_value( )

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

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)
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

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

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)
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

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

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
Q67. We can have duplicate indexes in Series?
(T/F)

a. True
b. False

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

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

Q71. Python libraries contain a collection of


built-in _____________
a. Data
b. Modules
c. Packages
d. Data Structure

Q72. What is “Pandas” in the following


statement?

import pandas as pd
a. Library
b. Module
c. Package
d. Function
Q73. Which of the following library help to
visualize data?

a. Pandas
b. Numpy
c. Matplotlib
d. Random

Q74. Which of the following is a high level data


manipulation tool used for analyzing data.?

a. Nump
b. Pandas
c. Matplotlib
d. Math

Q75. Pandas is the ____ librry.


a. Freeware
b. Proprietary
c. Open source
d. End source
Q76. Pandas Series is size __________ and value
___________

a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable

Q77. Pandas DataFrame is size ________ and


value ________

a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable

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

Q80. __________ is used when data is in Tabular


Format.
a. Pandas
b. Numpy
c. Both of the above
d. None of the above

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

Q82. By using Matplotlib, we can generate ____


a. Histograms
b. Bar charts
c. Scatterplots
d. All of the above

Q83. Installing Pandas is very similar to


installing ____________

a. Microsoft Word
b. Numpy
c. Python
d. MySQL

Q84. NumPy and Pandas can be installed only


when ________ is already installed on that
system.

a. Matplotlib
b. Python
c. Excel
d. Word

Q85. By default Series have _______ data labels


starting from ___.

a. character, ‘a’
b. numeric, one
c. numeric, zero
d. character, zero

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

Q87. What is the index value of “Ravi” in the


following Series?

import pandas as pd
S1 = pd.Series["Ram", "Raju", "Ravi",
"Ramesh", "Rishabh"]
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

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)
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

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

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)
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

Q94. Which of the following is parameter of


Series( ) function?

a. data
b. index
c. dtype
d. All of the above

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

Q97. Which of the following attribute is used to


check NaN value in Series?

a. hasNans
b. hasnans
c. Hasnans
d. HasNans

Q98. Which of the following attribute of Series


returns the tuple?

a. size
b. shape
c. values
d. index
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

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"])

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
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]

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
Q104. head( ) function return __________ n rows
and tail function return _____________ n rows
from a pandas object

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

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’

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

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

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]

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

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])

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

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’

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’

Q115. >>> S1[1:3] = 50 will update the value of


___________ elements

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

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”

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

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

Q120. Which of the following method is used to


subtract the two series?

a. subtract( )
b. subtraction( )
c. diff( )
d. sub( )

You might also like