Pandas Series Practice Questions
Pandas Series Practice Questions
a. NumPy
b. Pandas
c. Matplotlib
d. All of the above
a. Pandas
b. NumPy
c. Matplotlib
d. All of the above
a. Pandas
b. NumPy
c. Matplotlib
d. None of the above
Ans. b. Series
Q13. Which of the following statement is
wrong?
a. NumPy
b. Pandas
c. Matplotlib
d. None of the above
a. series( )
b. Series( )
c. createSeries( )
d. None of the above
>>> print(series1)
a. S1 = pd.Series(None)
b. S1 = pd.Series( )
c. Both of the above
d. None of the above
>>> 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
Jan 31
Feb 28
Mar 31
dtype: int64
import pandas as pd
S1 = pd.Series(data = range(31, 2, -6), index =
[x for x in "aeiou" ])
print(S1)
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)
a. True
b. False
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
a. index
b. data
c. values
d. None of the above
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
import pandas as pd
S1 = pd.Series(['NewDelhi', 'WashingtonDC',
'London', 'Paris'],
index=['India', 'USA', 'UK', 'France'])
print(S1['India', 'UK'])
a. print(S1[: : 1]
b. print(S1[: : -1]
c. print(S1[-1: : 1]
d. print(S1.reverse( ))
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'
a. name
b. index.name
c. size
d. Series.name
a. size
b. values
c. index
d. None of the above
a. index
b. size
c. empty
d. values
a. size
b. index
c. name
d. values
import pandas as pd
S1=pd.Series()
print(pd.Series().empty)
import pandas as pd
S1=pd.Series([1,2,3,4])
S2=pd.Series([7,8])
S3=S1+S2
print(S3.size)
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())
a. count
b. size
c. index
d. values
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
a. sum( )
b. addition( )
c. add( )
d. None of the above
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( )
a. add( )
b. mul( )
c. div( )
d. All of the above
a. >>>S1
b. >>> S1 > 40
c. >>>S1[S1 > 40]
d. None of the above
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
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
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
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
a. Nump
b. Pandas
c. Matplotlib
d. Math
a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable
a. Mutable, Mutable
b. Immutable, Immutable
c. Immutable, Mutable
d. Mutable, Immutable
a. Pandas
b. Matplotlib
c. Numpy
d. Math
a. Microsoft Word
b. Numpy
c. Python
d. MySQL
a. Matplotlib
b. Python
c. Excel
d. Word
a. character, ‘a’
b. numeric, one
c. numeric, zero
d. character, zero
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
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
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
a. data
b. index
c. dtype
d. All of the above
a. size
b. name
c. index.name
d. values
a. hasNans
b. hasnans
c. Hasnans
d. HasNans
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
import pandas as pd
S1=pd.Series([11, 12.5, None, 6],
index=["J","F","M","A"])
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]
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
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
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
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]
a. sort.values( )
b. sort_values( )
c. sort_value( )
d. sort_Values
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])
a. data
b. index
c. number
d. dtype
a. 1
b. 2
c. 3
d. 4
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
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
a. subtract( )
b. subtraction( )
c. diff( )
d. sub( )