Font size
WorksheetsPandas Series Quiz vl 24/1/25
Total questions: 93
Worksheet time: 54mins
Which of the following is true?
If data is an ndarray, index must be the same length as data.
Series is a one-dimensional labeled array capable of holding any data type.
Both of the above
None of the above
Pandas series is a combination of________
Records arranged in row and column
Collection of 1 dimensional data and associated index
Collection of 2 dimensional data
Collection of 3 dimensional data
Which of the following are ways to access series elements?
Using for loop
Indexing
Slicing
All of these
Which of the following is correct statement to create a series of multiple table of 3?
s = pd.Series(range(3,31,3))
s = pd.Series(range(3,3*11))
s = pd.Series(range(3,3,3))
All of these
To specify datatype int16 for a Series object, you can write :
pd.Series(data = array, dtype = int16)
pd.Series(data = array, dtype = numpy.int16)
pd.Series(data = array.dtype = pandas.int16)
all of the above
Pandas supports which of the following types of indexes?
Positional and Labelled Indexing
Numbered and Valued Indexing
Row and Column Indexing
Loop Indexing
Which of the following is correct statement to create a series of multiple repeated values 44,55 for three times?
s = pd.Series([44,55],3)
s = pd.Series(np.tile[44,55],3)
s = pd.Series(44,55,3)
s = pd.Series(range(44 and 55, 3))
Which of the following correct statement for creating empty series? (Assume that pandas library is already imported as pd)
ser = pd.Series(NaN)
ser = pd.Series(None)
ser = pd.Series()
ser = pd.Series
Which of the following is correct statement for creating a series to assign None to all series elements of 5 elements?
s = pd.Series()
s = pd.Series(None,index=[1,2,3,4,5])
s = pd.Series(none,5)
s = pd.Series(none*5)
Which one of the following is correct statement to create series 35,38,41,44 using a python sequence?
s = pd.Series(range(35,44,3))
s = pd.Series(range(35,45,3))
s = pd.Series(range(35 to 45,3))
s = pd.Series(range(35-45,3))
To get bottom 3 rows of a series, you may use _____ function.
tail()
tail(3)
bottom()
bottom(3)
To get top 5 rows of a series, you may use _____ function.
(e) both a and b
(a) head()
(b) head(5)
(d) top(5)
(c) top()
While importing pandas and numpy, you must use identifier name as pd and np only. Choose the correct answer
No, its not necessary
Yes, Always otherwise it will produce error
pd and np are keywords used for pandas and numpy
pd and np are identifiers used in the respective module
Which of the following attribute is used to returns the total number of rows?
countAll
size
shape
ndim
Which of the following attribute gives the following output - (4,) for following data frame?
s.shape()
s.index
s.shape
s.size
Ms. Priya is a python developer and she created a series using the following code, but she missed some of the lines given as blank. Fill that blanks and help her to complete the code: import pandas as pd import ________ as np s1=pd.Series([3,4,_____,44,67]) print(s1) Output: 0 3 1 4 2 NaN 3 44 4 67
numPy, no.None
numpy,np.nan
numpy,np.NaN
umPy,np.NaN
Which of the following is correct way of assigning a labelled index to series?
s=pd.Series(index=range(5,10),[22,33,44,56,78])
s=pd.Series(index=range(5,10),dt=[22,33,44,56,78])
s=pd.Series({22,33,44,56,78},index=range(5,10))
s=pd.Series([22,33,44,56,78],index=range(5,10))
Mr. Smit is trying to access 3rd element from series named s using positional index. Suggest him the correct statements from given statements:
s(2)
s{2}
s[2]
s[II]
The head function returns how many elements by default from the series?
2
3
4
5
The by default indexing is
Positional Index
Valued Index
Labelled Index
Sliced Index
________ index is takes user defined label as index.
Positional Index
Valued Index
Labelled Index
Sliced Index
Which of the following statement is fales with respect to accessing series elements through slicing?
It can be used as same as numpy or list slicing
It requires slicing start and end parameters
The values of last positional index is included
The series must be created with a sequence to access using slicing
Select the correct option to get the index preview in reverse order
s[-1::1]
s[-1:1:1]
s[::-1]
s[::]
Mr. Sidhhart wants to define the index explicitely for a series named s. Which of the following statement(s) is/are correct?
Statement 1: s.index=['1st', '2nd', '3rd', '4th'] Statement 2: s.index('1st', '2nd', '3rd', '4th')
Only Statement 1 is Correct
Only Statement 2 is Correct
Both statements are correct
None of these statements are correct
Series attributes are also known as series ____________
Methods
Events
Properties
Characteristics
Ms. Hetvee wants to check whether series is empty or not. But she is confused to how to do the same, help her to select the correct method out of the following?
s.empty()
s.empty
s.isempty
s.None
Mr. Asutosh has created a series with object s1 and assigned a name the index as 'states'. Which of the following statement should he use to print the index of series by assigned name?
s1.Index.Name
s1.index.name
s1.Name
s1.index
Which of the following function of series is used to return first 'n' elements from series?
s.head()
s.tail()
s.top()
s.on()
Which of the following attribute is used check whether a series contains NaN value or not?
s.NaN
s.None
s.hasnans
s.nan
Select the correct statement to assign a new name MySeries to a series object named 's'
s.Name('MySeries')
s.name='MySeries'
s('MySeries')
s.Name='MySeries'
Which of the following is the correct statement to access index 3rd and 5th values using positional index for series s?
s[3,5]
s[[3,5]]
s[(3,5)]
s([3,5])
Ms. Anita wants to print only list of values from the series. She should use which of the following attribute?
s.value
s.values
s.val
s.eval
What will be the output of following code: import pandas as pd s=pd.Series([11,12,13,14,15,16]) s[1:4] = 20 s=list(s) print(s) Select the correct output:
[11, 20, 20, 20, 15, 16]
[20, 20, 20, 20, 15, 16]
[20, 12, 13, 20, 15, 16]
[11, 20, 13, 20, 15, 16]
He wants to print Name and Values for Ritika and Mridul, which of the following command is correct:
s1.loc['Ritika','Mridul']
s1.loc['Ritika':'Mridul':3]
s1.loc['Ritika':'Mridul']
s1.loc['Ritika'-'Mridul']
Help to reset all values with 0 which ends with 7. Which of the following code is correct:
s1[s1/10==7]=0
s1[s1%10==7]=0
s1[s1//10==7]=0
s1[s1**7]=0
What will be output of: print(s1.shape)
(6,)
6
[6]
{6}
He wants to check the availability of NaN values in index. Which of the following is correct statement for him?
s1.none
s1.nan
s1.hasnans
s1.hasNan
He wants to return total number elements from the series. Which of these statement is correct?
s1.index
s1.length
s1.itemsize
s1.size
He wants to check whether series is empty or not?
s1.empty
s1.none
s1.blank
s1.zero
Series is 1-D labelled array having two parts i.e. Index, Data. We can create series from:
Python Sequence , Dictionary
All 4 ( ie Python Sequence , Dictionary , Scalar value , Numpy Array)
Scalar value , Numpy Array
None of stated option.
What will be the output of following code- import pandas as pd Myseries3=pd.Series([1, 2, 2, 7, 'Learnpython4cbse', 77.5]) print(Myseries3.head())
Last data elements of series along with its indices i.e. -1.
First data element of series along with its indices i.e. 0.
Entire series
First five data elements of series along with its indices i.e. 0,1,2,3,4 respectively
To have output of below python code as shown in figure, identify which attribute can be used to fill in the blank. import pandas as pd Lst2=[11,12,13,14] Myseries2=pd.Series(Lst2, index = ["I", "ll", "III", "IV" ]) print(Myseries2.____________[ "II" : ])
loc[ ]
iloc[ ]
loc [ ] or iloc[ ]
Neither loc [ ] nor loc [ ]
Which index, data elements will be printed by below code as output : import pandas as pd Lst1 = [11,12,13,14] Myseries2 = pd.Series(Lst1) print(Myseries2,loc[2:])
Data : 12,13,14 along with series-index 1,2,3
Data : 13,14 along with series-index 'C','D'
Data : 13,14 along with series-index 2,3
Data : 12,13,14 along with series-index 'B','C','D'
Predict data elements of Myseries1 : import pandas as pd Myseries1 = pd.Series(5,index=["A", "B", "C", "D"]) print(Myseries1)
5,1,1,1
5,0,0,0
5,1,5,1
5,5,5,5
While trying to create series from dictionary, keys of dictionary become index.
True
False
Depends on Python Version
Depends on Machine Configuration
Fill in the blanks : # Series Creation from List with custom indexing import pandas as pd Lst = [11,12,13,14] Series1 = pd.Series(Lst, ____________= [ "1st", "2nd", "3rd", "4th" ])
row
index
row index
Any above option
Which of the following is not a correct statement to delete the element stored at 3rd position?
del s[3]
s.pop(3)
s.drop(3)
s.delete(3)
Surmay is a new learner for the python pandas series. He learned some of the concepts of python in class 11 with NumPy module. He wants to create a series of values multiplied by 7 between 20 to 30 with the following code. The index should be between 20 to 30 and every value be multiply by 7. Help him to create series by following code: import pandas as pd import numpy as np s=np.arange(20,30) sm7= pd.Series(s,s*7) sm7=pd.Series(s*7,s) sm7=pd.Series([s*7],index=s) All of these
Ms. Ankita wants to apply the name for the index in series named sal for month wise salary of her employees. Choose the correct statement for her:
s.index='Month'
s.index.name='Month'
s.index('Month')
s.index.name['Month']
Which of the following statement is correct with respect to loc and iloc?
both are used for to access values based on index labels
iloc does not include the last element of the range
loc does not include the last element of the series
All of the above are correct
Which of the following code is helpful to access the first 3 index values?
s[:3]
s[::3]
s[3:]
s[:3:]
Mrs. Payal Mishra wanted to access multiple index value from series 's'. Which of the following statement is correct for her?
s.index=[0,1,2,3,4]
s.index(0,1,2,3,4)
s[0,1,2,3,4]
s[[0,1,2,3,4]]
What will be the output of following code? import pandas as pd s=pd.Series([10,20,30,40,50], index={'a','b'','c','d','e'}) print(s['d'])
d
30
40
4
What will be correct syntax for pandas series?
pandas Series( data, index, dtype)
panda.series( data, index, dtype)
pandas.Series( data, index, dtype)
panda Series( data, index, dtype)
Choose correct option : Assume there is a series s1 having data elements as 11, 12, and 13 respectively. Programmer 'Manoj' wrote print(s1+2) in his python program. Statement 1: A series will data elements as 13, 14, 15 will get printed. Statement 2: Series supports vectorized operation.
Only Statement 1 is true.
Only Statement 2 is true.
Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.
Identify incorrect syntax for importing pandas library :
A. import pandas as p1 s1=p1.Series( [11 , 12 , 13])
B. import pandas s1=p1.Series( [11 , 12 , 13])
C. from pandas import Series s1=Series( [11 , 12 , 13])
D. import pandas s1=pandas.Series( [11 , 12 , 13])
Identify false statement regarding series data structure of pandas library : (a) Series is homogeneous data structure. (b) Series is a two dimensional data structure. (c)Size of series is mutable. (d) Both (b) & (c)
Predict output : import pandas as p1 s1=p1.Series( [11,12,13,14]) print(s1.index)
Syntax Error
[ 0, 1, 2, 31]
['I', 'II', 'III', 'IV']
['A', 'B', 'C', 'D']
Choose correct option: import pandas as p1 import numpy as np a1=np.arange(2,11,2) s1=p1.Series(a1,index = list('ABCDE')) print(s1.ndim) Statement 1: Above code will give output as 1. Statement 2: Series is a one dimensional data structure.
Only Statement 1 is true.
Only Statement 2 is true.
Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.
Which of the following are modules/libraries in Python?
NumPy
Pandas
Matplotlib
All of the above
Identify out of below options, which could correct below code in order to help Rohit. Line 1: import pandas as p1 Line 2: Lst1=[ 1, 2,3] Line 3: Lst2= list('ABC') Line 4: S1= p1. ser
Identify out of below options, which could correct below code in order to help Rohit. Line 1: import pandas as p1 Line 2: Lst1=[ 1, 2,3] Line 3: Lst2= list('ABC') Line 4: S1= p1. series( Lst1, rows=Lst2)
In Line-4, Use p1.Series instead of p1.series.
In Line-4, Use 'index' attribute instead of rows attribute.
Both of the above option
In Line-1, use import pandas only.
Choose correct option : import pandas as p1 Lst = [11,12,13,14] s1=p1.Series(Lst , index = list('abc')) Statement 1: No. of indexes should be equal to number of data elements in series. Statement 2: Above code will execute fine.
Only Statement 1 is true.
Only Statement 2 is true.
Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.
Which of the following code will generate the following output? Jan 31 Feb 28 Mar 31 dtype: int64
A. import pandas S1 = pd.Series(data = [31,28,31], index=["Jan","Feb","Mar"]) print(S1)
B. import pandas as pd S1 = p1.series([31,28,31], index=["Jan","Feb","Mar"]) print(S1)
C. import pandas as pd S1 = pd.Series([31,28,31], columns=["Jan","Feb","Mar"]) print(S1)
D. import pandas as pd S1 = pd.Series([31,28,31], index=["Jan","Feb","Mar"]) print(S1)
To get last element of series s1, we may use s1._________function.
tail(1)
tail()
last[1]
last[-1]
Rohan wants to create a series from a list, having index as 'A' , 'B','C' respectively. However, below code is generating error. Identify which lines are responsible for generating error. Line 1: import pandas as p1 Line 2: Lst1=[ 1, 2,3] Line 3: Lst2= list('ABC') Line 4: S1= p1. series( Lst1, rows=Lst2)
Line 4
Line 3
Line 2
Line 1
Choose correct option: Reena created a series s1 having data elements as 12, 13, 14, 15 with index as I1, I2, I3,I4 respectively. She is using code either s1.loc[ 'I2' : 'I3' ] or s1.iloc[ 1 : 3 ] Statement 1: Both code will give identical output. Statement 2: Both codes can be used to access data elements as 13,14,15 respectively.
Only Statement 1 is true.
Only Statement 2 is true.
Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.
Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.
To create an empty Series object , we can use:
pd.Series(empty)
pd.Series(numpy.NaN)
pd.Series()
Any of above mentioned options
To access elements as 12,13,14 respectively , what python command can be used: import pandas as pd Lst1=[11,12,13,14,15] Srs1=pd.Series(Lst1, index-['a', 'b','c', 'd', 'e']) Srs1.iloc[1:4] orSr s1.loc[ 'b': 'd' ]
Srs1.iloc[1:4]
Srs1.iloc[ 'b': 'd' ]
Neither Srs1.iloc[1:3] nor Srs1.loc[ 'b': 'd' ]
To get the number of dimensions of Series object, __________attribute is used.
size
shape
itemsize
ndim
Aman , Riya and Neha are involved in a group discussion. All 3 students are representing below statements : Aman : Series is a one dimensional data structure. Riya : Series can have only default index ie 0,1,2. Thus, these index can't be customised. Neha : Size of series is immutable . Thus, it can't be changed once declare. Identify which student(s) is/are representing wrong fact(s).
Aman
Both Aman and Riya
Neha
Riya
Which of the following command is used to install pandas?
pip install pandas
install pandas
pip pandas
None of the above
To create an empty Series Object , You can use:
pandas.Series(empty)
pandas.Series(np.Nan)
pandas.Series()
all of these
Given a pandas series called Sequences, the command which will display the first 4 rows is______
print(Sequences.head(4))
print(Sequences.Head(4))
print(Sequences.heads(4))
print(Sequences.Heads(4))
To display first three elements of a Series object S, you may write_______.
S[:3]
S[3]
S[3rd]
All of these
To specify datatype for a Series object,________ argument is used.
Datatype
Type
dtype
Dtype
How can we create a Series 'S1' based on 'S' with all its elements doubled.
S1=pd.Series(S*2)
S1=pd.Series(data=S*2)
S1=S*2
All of the above
To display third element of a Series object S, you will write_________.
S[ : 3]
S[ : 2]
S[3]
S[2]
Consider the following two series objects S1 , S2 Series - S1 0 10 1 18 Series - S2 a 5 b 6 What will be the output of S1+S2
(A) 0 NaN 1 NaN a NaN b NaN
(B) 0 10 1 18 a 5 b 6
(C) 0 15 1 24
(D) a 15 b 24
The________function on Series object returns only the count of non-NaN values in it.
count()
total()
length()
len()
A____________is a pandas data structure that represents a 1-D array like object.
Array
Numpy
Series
Dataframe
Find the output of the given code. import pandas as pd s=pd.Series(['a','s','r'],index=[2,6,9]) print(s>='s')
(A) 2 False 6 False 9 True
(B) 2 False 6 True 9 False
(C) 2 False 6 False 9 False
(D) 2 True 6 False 9 True
To display last five rows of a Series object S, You may write___________.
(a) head()
(b) head(5)
(c) tail()
(d) tail(5)
(e) both c and d
To get the number of bytes of the Series data,___________attribute is displayed.
hasnans
nbytes
ndim
dtype
You can use numpy.__________for missing data.
NaN
Missing
None
NULL
To get the number of dimensions of a Series object,_______attribute is displayed.
index
size
itemsize
ndim
Missing data in pandas object is represented through:
null
none
missing
nan
How to reset sale to 0 in Series 'Sale'.
Sale[::]=0
Sale[:]=0
Both of the above option
None of the above
To get the number of elements in a Series object,____________attribute may be used.
index
size
itemsize
ndim
To check if the Series object contains NaN values,__________ attribute is displayed.
hasnans
nbytes
ndim
dtype
The_________function on Series object returns total elements in it including NaNs.
Total()
len()
length()
total()
To specify datatype int16 for a Series object, you can write:
pandas.Series(data=array,dtype=int16)
pandas.Series(data=array,dtype=numpy.int16)
pandas.Series(data=array.dtype=pandas.int16)
All of the above
How to alter the index of Series Sale to weekday names like sun,mon..etc.
Sale.rename(index=['sun','mon','tue','wed','thu','fri','sat'])
Sale.renameindex=['sun','mon','tue','wed','thu','fri','sat']
Sale.index=['sun','mon','tue','wed','thu','fri','sat']
Sale.index(['sun','mon','tue','wed','thu','fri','sat'])
