Home
MCQS
Python MCQ Quiz Hub
Pandas MCQ Questions Set 2
Choose a topic to test your knowledge and improve your Python skills
1. 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'])
print(S1[0])
print(S1[‘India’])
Both of the above
print(S1.India)
2. We can access elements in Series by using ________ index and ____________index.
Numeric, labelled
Positional, Naming
Positional, labelled
None of the above
3. 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'])
India NewDelhi UK London dtype: object
India NewDelhi UK Washington dtype: object
Error
None of the above
4. Which of the following statement will print Series ‘S1’ in reverse order?
print(S1[: : 1]
print(S1[: : -1]
print(S1[-1: : 1]
print(S1.reverse( ))
5. 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'
1
2
3
4
6. 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'
name
index.name
size
Series.name
7. S1.values will return all the values of Series ‘S1’ in ___
Tuple
Dictionary
List
String
8. Which of the following property/attribute return total number of values in Series ‘S1’?
size
values
index
None of the above
9. Which of the following attributes returns True if there is no value in Series?
index
size
empty
values
10. Which of the following attributes returns all the values of Series?
size
index
name
values
11. Write the output of the following code: import pandas as pd S1=pd.Series() print(pd.Series().empty)
True
False
Error
None of the above
12. 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)
2
4
6
Error
13. Which of the following statement shows first five values of Series ‘S1’?
S1.head( )
S1.head( 5 )
Both of the above
None of the above
14. 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())
6
4
2
0
15. Which of the following returns number of non-NaN values of Series?
count
size
index
values
16. 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())
8
6
0
6
17. We can perform _____________ on two series in Pandas.
Addition
Subtraction
Multiplication
All the above
18. Which of the following method is used to add two series?
sum( )
addition( )
add( )
None of the above
19. Which of the following statement will display the difference of two Series ‘A’ and ‘B’?
>>>A – B
>>>A.sub(B)
Both of the above
None of the above
20. Which of the following fills the missing values in Series? a.
fill value
fill-value
fill_value
fill_value( )
21. Which of the following function is used for basic mathematical operations in Series?
add( )
mul( )
div( )
All the above
22. Which of the following statement is replacing missing values of Series A and Series B by 100 .
>>> A.add(B, fill_value = 100)
>>>A.add(B, fill_value : 100)
>>> A.add(B, fill-value = 100)
>>> A.add(B, fill-value = 100)
23. Mathematical Operations on two Series object is done by matching ______
indexes
values
Both of the above
None of the above
24. Which of the following statement will display values more than 40 from Series ‘S1’?
>>>S1
>>> S1 > 40
>>>S1[S1 > 40]
None of the above
25. Which of the following statement will return 10 values from the bottom/end of the Series ‘S1’?
S1.tail( )
S1.tail(10)
S1.head(10)
S1(10)
26. Which of the following are valid operations on Series ‘S1’?
>>> S1 + 2
>>> S1 ** 2
>>> S1 * 2
All the above
27. When an operation is carried out on every value of Series object is called __
Scalar Operation
Vector Operation
Both of the above
None of the above
28. Which of the following statement will modify the first three values of Series ‘S1’?
S1[0, 1, 2] = 100
S1[0 : 3] = 100
S1[ : 3] = 100
All the above
29. 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'])
‘c’
2
Both of the above
None of the above
30. S2 is ____________ in given code ? S2 = S1[2 : 5] #S1 is a Series object
List
Tuple
Series
All the above
31. Python libraries contain a collection of built-in __
Data
Modules
Packages
Data Structure
32. Which of the following library help to visualize data?
Pandas
Numpy
Matplotlib
Random
33. Which of the following is a high level data manipulation tool used for analyzing data.?
Nump
Pandas
Matplotlib
Math
34. Pandas is the ____ library.
Freeware
Proprietary
Open source
End source
35. Pandas Series is size __________ and value _____
Mutable, Mutable
Immutable, Immutable
Immutable, Mutable
Mutable, Immutable
36. Pandas DataFrame is size ________ and value ____
Mutable, Mutable
Immutable, Immutable
Immutable, Mutable
Mutable, Immutable
37. data’ in the following code could be _____ S1 = pd.Series(data)
Python sequence
Scalar value
Python dictionary
All the above
38. Choose the correct statement : Statement1 : A Numpy array requires homogeneous data. Statement2 : Pandas DataFrame can have heterogeneous data.
Statement1 is correct
Statement2 is correct
Both the statements are correct
Both the statements are wrong
39. 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
Pandas
Matplotlib
Numpy
Math
40. By using Matplotlib, we can generate __
Histograms
Bar charts
Scatterplots
All the above
41. Installing Pandas is very similar to installing __
Microsoft Word
Numpy
Python
MySQL
42. By default Series have _______ data labels starting from ___.
character, ‘a’
numeric, one
numeric, zero
character, zero
43. Write a statement to import pandas with alias name ‘pds’
import pandas as pds
Import pandas as pds
import panda as pds
import Pandas as pds
44. What is the index value of “Ravi” in the following Series? import pandas as pd S1 = pd.Series["Ram", "Raju", "Ravi", "Ramesh", "Rishabh"]
0
1
2
3
45. 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
Month name, Numbers
Numbers, Month name
Month name, Month name
Numbers, Numbers
46. 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)
float64
int64
object
string
47. How many elements will be there in given series ‘S1’? import pandas as pd S1=pd.Series('python practice') print(S1)
0
1
2
15
48. Two common ways for accessing the elements of a series are _________ and ____
Indexing, Concatenation
Labelled Indexing, Positional Indexing
Indexing, Slicing
Slicing, Cutting
49. 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)
1
3
5
4
50. Which of the following statement is correct to add NaN value in series?
S1=pd.Series([10, np.NaN,11])
S1=pd.Series([10, None, 11])
Both of the above
None of the above
51. Which of the following is parameter of Series( ) function?
data
index
dtype
All the above
52. What is the data type of series ‘S1’ given below ? S1=pd.Series([11, 12.5, “ok”])
int64
float64
object
object64
53. Which of the following attribute of Series is used to set the name of Series object?
size
name
index.name
values
54. Which of the following attribute is used to check NaN value in Series?
hasNans
hasnans
Hasnans
HasNans
55. Which of the following attribute of Series returns the tuple?
size
shape
values
index
56. What type of error is returned, when the length of index and the length of data in Series() function is not same?
Key Error
Value Error
Syntax Error
Name Error
57. 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"])
print(S1[1])
print(S1[“J”])
print(S1[0])
print(S1[“F”])
58. Can a Series have duplicate index value?
yes
no
Yes, Only series with integer values
Yes, Only series with character values
59. Rosy wants to display the series ‘S1’ in reverse order. Help her to find the correct code.
>>> S1[ : : 1]
>>> S1[ : : -1]
>>> S1[ -1 : :]
>>> S1[ : 1 1]
60. 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
S1[ : 2] = 50 b.
S1[0 : 2] = 50
Both of the above
None of the above
61. S1[0 : 2] = 50
last, first
first, second
last, seven
first, last
62. 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
5
6
7
8
63. 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’?
2
3
4
5
64. 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
Statement 1
Statement 2
Statement 3
None of the above
65. 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
Statement 1
Statement 2
Statement 3
None of the above
66. 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
print(Seremp > 20000)
print(Seremp (Seremp> 20000) )
print(Seremp [Seremp > 20000] )
print[Seremp> 20000]
67. _________ function is used to sort a Series object on the basis of values.
sort.values( )
sort_values( )
sort_value( )
sort_Values
68. 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])
S1=pd.Series(data=[11, 12, 5, 6,9],index=[1,2,3,4,5])
S1=pd.Series([11, 12, 5, 6,9],index=[1,2,3,4,5])
S1=pd.Series([11, 12, 5, 6,9],[1,2,3,4,5])
S1=pd.Series(data=[11, 12, 5, 6,9], [1,2,3,4,5])
69. 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.
data
index
number
dtype
70. 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.
In iloc( ) method, we have to pass an integer index.
This method include the last element of the range passed.
S1.iloc[3] will display fourth value of Series ‘S1’
S1.iloc[:3] will display first three values of Series ‘S1’
71. print(S1[-1]) will return ___________ #’S1′ is a series
last element of series ‘S1’
first element of series ‘S1’
Key Error
all elements of series ‘S1’
72. >>> S1[1:3] = 50 will update the value of ___________ elements
1
2
3
4
73. _________ statement will assigns a name to the Series ‘S1’.
>>> S1.name = “Empl”
>>> S1_name = “Empl”
>>> S1[name] = “Empl”
>>> S1.indexname = “Empl”
74. 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())
4
6
5
Error
75. While performing mathematical operations on series, index matching is implemented and all missing values are filled in with ___________ by default
NaN
None
0
1
76. 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.
print(Feb_Sal + Jan_Sal)
print(Feb_Sal_add_Jan_Sal)
print(Feb_Sal plus Jan_Sal)
None of the above
77. Which of the following method is used to subtract the two series?
subtract( )
subtraction( )
diff( )
sub( )
Submit