wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Pandas Series Quiz vl 24/1/25

Total questions: 93

Worksheet time: 54mins

Name
Class
Date
1.

Which of the following is true?

a)

If data is an ndarray, index must be the same length as data.

b)

Series is a one-dimensional labeled array capable of holding any data type.

c)

Both of the above

d)

None of the above

2.

Pandas series is a combination of________

a)

Records arranged in row and column

b)

Collection of 1 dimensional data and associated index

c)

Collection of 2 dimensional data

d)

Collection of 3 dimensional data

3.

Which of the following are ways to access series elements?

a)

Using for loop

b)

Indexing

c)

Slicing

d)

All of these

4.

Which of the following is correct statement to create a series of multiple table of 3?

a)

s = pd.Series(range(3,31,3))

b)

s = pd.Series(range(3,3*11))

c)

s = pd.Series(range(3,3,3))

d)

All of these

5.

To specify datatype int16 for a Series object, you can write :

a)

pd.Series(data = array, dtype = int16)

b)

pd.Series(data = array, dtype = numpy.int16)

c)

pd.Series(data = array.dtype = pandas.int16)

d)

all of the above

6.

Pandas supports which of the following types of indexes?

a)

Positional and Labelled Indexing

b)

Numbered and Valued Indexing

c)

Row and Column Indexing

d)

Loop Indexing

7.

Which of the following is correct statement to create a series of multiple repeated values 44,55 for three times?

a)

s = pd.Series([44,55],3)

b)

s = pd.Series(np.tile[44,55],3)

c)

s = pd.Series(44,55,3)

d)

s = pd.Series(range(44 and 55, 3))

8.

Which of the following correct statement for creating empty series? (Assume that pandas library is already imported as pd)

a)

ser = pd.Series(NaN)

b)

ser = pd.Series(None)

c)

ser = pd.Series()

d)

ser = pd.Series

9.

Which of the following is correct statement for creating a series to assign None to all series elements of 5 elements?

a)

s = pd.Series()

b)

s = pd.Series(None,index=[1,2,3,4,5])

c)

s = pd.Series(none,5)

d)

s = pd.Series(none*5)

10.

Which one of the following is correct statement to create series 35,38,41,44 using a python sequence?

a)

s = pd.Series(range(35,44,3))

b)

s = pd.Series(range(35,45,3))

c)

s = pd.Series(range(35 to 45,3))

d)

s = pd.Series(range(35-45,3))

11.

To get bottom 3 rows of a series, you may use _____ function.

a)

tail()

b)

tail(3)

c)

bottom()

d)

bottom(3)

12.

To get top 5 rows of a series, you may use _____ function.

a)

(e) both a and b

b)

(a) head()

c)

(b) head(5)

d)

(d) top(5)

e)

(c) top()

13.

While importing pandas and numpy, you must use identifier name as pd and np only. Choose the correct answer

a)

No, its not necessary

b)

Yes, Always otherwise it will produce error

c)

pd and np are keywords used for pandas and numpy

d)

pd and np are identifiers used in the respective module

14.

Which of the following attribute is used to returns the total number of rows?

a)

countAll

b)

size

c)

shape

d)

ndim

15.

Which of the following attribute gives the following output - (4,) for following data frame?

a)

s.shape()

b)

s.index

c)

s.shape

d)

s.size

16.

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

a)

numPy, no.None

b)

numpy,np.nan

c)

numpy,np.NaN

d)

umPy,np.NaN

17.

Which of the following is correct way of assigning a labelled index to series?

a)

s=pd.Series(index=range(5,10),[22,33,44,56,78])

b)

s=pd.Series(index=range(5,10),dt=[22,33,44,56,78])

c)

s=pd.Series({22,33,44,56,78},index=range(5,10))

d)

s=pd.Series([22,33,44,56,78],index=range(5,10))

18.

Mr. Smit is trying to access 3rd element from series named s using positional index. Suggest him the correct statements from given statements:

a)

s(2)

b)

s{2}

c)

s[2]

d)

s[II]

19.

The head function returns how many elements by default from the series?

a)

2

b)

3

c)

4

d)

5

20.

The by default indexing is

a)

Positional Index

b)

Valued Index

c)

Labelled Index

d)

Sliced Index

21.

________ index is takes user defined label as index.

a)

Positional Index

b)

Valued Index

c)

Labelled Index

d)

Sliced Index

22.

Which of the following statement is fales with respect to accessing series elements through slicing?

a)

It can be used as same as numpy or list slicing

b)

It requires slicing start and end parameters

c)

The values of last positional index is included

d)

The series must be created with a sequence to access using slicing

23.

Select the correct option to get the index preview in reverse order

a)

s[-1::1]

b)

s[-1:1:1]

c)

s[::-1]

d)

s[::]

24.

Mr. Sidhhart wants to define the index explicitely for a series named s. Which of the following statement(s) is/are correct?

a)

Statement 1: s.index=['1st', '2nd', '3rd', '4th'] Statement 2: s.index('1st', '2nd', '3rd', '4th')

b)

Only Statement 1 is Correct

c)

Only Statement 2 is Correct

d)

Both statements are correct

e)

None of these statements are correct

25.

Series attributes are also known as series ____________

a)

Methods

b)

Events

c)

Properties

d)

Characteristics

26.

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?

a)

s.empty()

b)

s.empty

c)

s.isempty

d)

s.None

27.

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?

a)

s1.Index.Name

b)

s1.index.name

c)

s1.Name

d)

s1.index

28.

Which of the following function of series is used to return first 'n' elements from series?

a)

s.head()

b)

s.tail()

c)

s.top()

d)

s.on()

29.

Which of the following attribute is used check whether a series contains NaN value or not?

a)

s.NaN

b)

s.None

c)

s.hasnans

d)

s.nan

30.

Select the correct statement to assign a new name MySeries to a series object named 's'

a)

s.Name('MySeries')

b)

s.name='MySeries'

c)

s('MySeries')

d)

s.Name='MySeries'

31.

Which of the following is the correct statement to access index 3rd and 5th values using positional index for series s?

a)

s[3,5]

b)

s[[3,5]]

c)

s[(3,5)]

d)

s([3,5])

32.

Ms. Anita wants to print only list of values from the series. She should use which of the following attribute?

a)

s.value

b)

s.values

c)

s.val

d)

s.eval

33.

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:

a)

[11, 20, 20, 20, 15, 16]

b)

[20, 20, 20, 20, 15, 16]

c)

[20, 12, 13, 20, 15, 16]

d)

[11, 20, 13, 20, 15, 16]

34.

He wants to print Name and Values for Ritika and Mridul, which of the following command is correct:

a)

s1.loc['Ritika','Mridul']

b)

s1.loc['Ritika':'Mridul':3]

c)

s1.loc['Ritika':'Mridul']

d)

s1.loc['Ritika'-'Mridul']

35.

Help to reset all values with 0 which ends with 7. Which of the following code is correct:

a)

s1[s1/10==7]=0

b)

s1[s1%10==7]=0

c)

s1[s1//10==7]=0

d)

s1[s1**7]=0

36.

What will be output of: print(s1.shape)

a)

(6,)

b)

6

c)

[6]

d)

{6}

37.

He wants to check the availability of NaN values in index. Which of the following is correct statement for him?

a)

s1.none

b)

s1.nan

c)

s1.hasnans

d)

s1.hasNan

38.

He wants to return total number elements from the series. Which of these statement is correct?

a)

s1.index

b)

s1.length

c)

s1.itemsize

d)

s1.size

39.

He wants to check whether series is empty or not?

a)

s1.empty

b)

s1.none

c)

s1.blank

d)

s1.zero

40.

Series is 1-D labelled array having two parts i.e. Index, Data. We can create series from:

a)

Python Sequence , Dictionary

b)

All 4 ( ie Python Sequence , Dictionary , Scalar value , Numpy Array)

c)

Scalar value , Numpy Array

d)

None of stated option.

41.

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

a)

Last data elements of series along with its indices i.e. -1.

b)

First data element of series along with its indices i.e. 0.

c)

Entire series

d)

First five data elements of series along with its indices i.e. 0,1,2,3,4 respectively

42.

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

a)

loc[ ]

b)

iloc[ ]

c)

loc [ ] or iloc[ ]

d)

Neither loc [ ] nor loc [ ]

43.

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

a)

Data : 12,13,14 along with series-index 1,2,3

b)

Data : 13,14 along with series-index 'C','D'

c)

Data : 13,14 along with series-index 2,3

d)

Data : 12,13,14 along with series-index 'B','C','D'

44.

Predict data elements of Myseries1 : import pandas as pd Myseries1 = pd.Series(5,index=["A", "B", "C", "D"]) print(Myseries1)

a)

5,1,1,1

b)

5,0,0,0

c)

5,1,5,1

d)

5,5,5,5

45.

While trying to create series from dictionary, keys of dictionary become index.

a)

True

b)

False

c)

Depends on Python Version

d)

Depends on Machine Configuration

46.

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

a)

row

b)

index

c)

row index

d)

Any above option

47.

Which of the following is not a correct statement to delete the element stored at 3rd position?

a)

del s[3]

b)

s.pop(3)

c)

s.drop(3)

d)

s.delete(3)

48.

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

4 lines
49.

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:

a)

s.index='Month'

b)

s.index.name='Month'

c)

s.index('Month')

d)

s.index.name['Month']

50.

Which of the following statement is correct with respect to loc and iloc?

a)

both are used for to access values based on index labels

b)

iloc does not include the last element of the range

c)

loc does not include the last element of the series

d)

All of the above are correct

51.

Which of the following code is helpful to access the first 3 index values?

a)

s[:3]

b)

s[::3]

c)

s[3:]

d)

s[:3:]

52.

Mrs. Payal Mishra wanted to access multiple index value from series 's'. Which of the following statement is correct for her?

a)

s.index=[0,1,2,3,4]

b)

s.index(0,1,2,3,4)

c)

s[0,1,2,3,4]

d)

s[[0,1,2,3,4]]

53.

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

a)

d

b)

30

c)

40

d)

4

54.

What will be correct syntax for pandas series?

a)

pandas Series( data, index, dtype)

b)

panda.series( data, index, dtype)

c)

pandas.Series( data, index, dtype)

d)

panda Series( data, index, dtype)

55.

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.

a)

Only Statement 1 is true.

b)

Only Statement 2 is true.

c)

Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.

d)

Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

56.

Identify incorrect syntax for importing pandas library :

a)

A. import pandas as p1 s1=p1.Series( [11 , 12 , 13])

b)

B. import pandas s1=p1.Series( [11 , 12 , 13])

c)

C. from pandas import Series s1=Series( [11 , 12 , 13])

d)

D. import pandas s1=pandas.Series( [11 , 12 , 13])

57.

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)

4 lines
58.

Predict output : import pandas as p1 s1=p1.Series( [11,12,13,14]) print(s1.index)

a)

Syntax Error

b)

[ 0, 1, 2, 31]

c)

['I', 'II', 'III', 'IV']

d)

['A', 'B', 'C', 'D']

59.

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.

a)

Only Statement 1 is true.

b)

Only Statement 2 is true.

c)

Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.

d)

Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

60.

Which of the following are modules/libraries in Python?

a)

NumPy

b)

Pandas

c)

Matplotlib

d)

All of the above

61.

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

4 lines
62.

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)

a)

In Line-4, Use p1.Series instead of p1.series.

b)

In Line-4, Use 'index' attribute instead of rows attribute.

c)

Both of the above option

d)

In Line-1, use import pandas only.

63.

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.

a)

Only Statement 1 is true.

b)

Only Statement 2 is true.

c)

Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.

d)

Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

64.

Which of the following code will generate the following output? Jan 31 Feb 28 Mar 31 dtype: int64

a)

A. import pandas S1 = pd.Series(data = [31,28,31], index=["Jan","Feb","Mar"]) print(S1)

b)

B. import pandas as pd S1 = p1.series([31,28,31], index=["Jan","Feb","Mar"]) print(S1)

c)

C. import pandas as pd S1 = pd.Series([31,28,31], columns=["Jan","Feb","Mar"]) print(S1)

d)

D. import pandas as pd S1 = pd.Series([31,28,31], index=["Jan","Feb","Mar"]) print(S1)

65.

To get last element of series s1, we may use s1._________function.

a)

tail(1)

b)

tail()

c)

last[1]

d)

last[-1]

66.

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)

a)

Line 4

b)

Line 3

c)

Line 2

d)

Line 1

67.

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.

a)

Only Statement 1 is true.

b)

Only Statement 2 is true.

c)

Both Statement 1 and 2 are true, but Statement 2 is not correct reasoning of Statement 1.

d)

Both Statement 1 and 2 are true, but Statement 2 is correct reasoning of Statement 1.

68.

To create an empty Series object , we can use:

a)

pd.Series(empty)

b)

pd.Series(numpy.NaN)

c)

pd.Series()

d)

Any of above mentioned options

69.

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

a)

Srs1.iloc[1:4]

b)

Srs1.iloc[ 'b': 'd' ]

c)

Neither Srs1.iloc[1:3] nor Srs1.loc[ 'b': 'd' ]

70.

To get the number of dimensions of Series object, __________attribute is used.

a)

size

b)

shape

c)

itemsize

d)

ndim

71.

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

a)

Aman

b)

Both Aman and Riya

c)

Neha

d)

Riya

72.

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

73.

To create an empty Series Object , You can use:

a)

pandas.Series(empty)

b)

pandas.Series(np.Nan)

c)

pandas.Series()

d)

all of these

74.

Given a pandas series called Sequences, the command which will display the first 4 rows is______

a)

print(Sequences.head(4))

b)

print(Sequences.Head(4))

c)

print(Sequences.heads(4))

d)

print(Sequences.Heads(4))

75.

To display first three elements of a Series object S, you may write_______.

a)

S[:3]

b)

S[3]

c)

S[3rd]

d)

All of these

76.

To specify datatype for a Series object,________ argument is used.

a)

Datatype

b)

Type

c)

dtype

d)

Dtype

77.

How can we create a Series 'S1' based on 'S' with all its elements doubled.

a)

S1=pd.Series(S*2)

b)

S1=pd.Series(data=S*2)

c)

S1=S*2

d)

All of the above

78.

To display third element of a Series object S, you will write_________.

a)

S[ : 3]

b)

S[ : 2]

c)

S[3]

d)

S[2]

79.

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)

(A) 0 NaN 1 NaN a NaN b NaN

b)

(B) 0 10 1 18 a 5 b 6

c)

(C) 0 15 1 24

d)

(D) a 15 b 24

80.

The________function on Series object returns only the count of non-NaN values in it.

a)

count()

b)

total()

c)

length()

d)

len()

81.

A____________is a pandas data structure that represents a 1-D array like object.

a)

Array

b)

Numpy

c)

Series

d)

Dataframe

82.

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)

(A) 2 False 6 False 9 True

b)

(B) 2 False 6 True 9 False

c)

(C) 2 False 6 False 9 False

d)

(D) 2 True 6 False 9 True

83.

To display last five rows of a Series object S, You may write___________.

a)

(a) head()

b)

(b) head(5)

c)

(c) tail()

d)

(d) tail(5)

e)

(e) both c and d

84.

To get the number of bytes of the Series data,___________attribute is displayed.

a)

hasnans

b)

nbytes

c)

ndim

d)

dtype

85.

You can use numpy.__________for missing data.

a)

NaN

b)

Missing

c)

None

d)

NULL

86.

To get the number of dimensions of a Series object,_______attribute is displayed.

a)

index

b)

size

c)

itemsize

d)

ndim

87.

Missing data in pandas object is represented through:

a)

null

b)

none

c)

missing

d)

nan

88.

How to reset sale to 0 in Series 'Sale'.

a)

Sale[::]=0

b)

Sale[:]=0

c)

Both of the above option

d)

None of the above

89.

To get the number of elements in a Series object,____________attribute may be used.

a)

index

b)

size

c)

itemsize

d)

ndim

90.

To check if the Series object contains NaN values,__________ attribute is displayed.

a)

hasnans

b)

nbytes

c)

ndim

d)

dtype

91.

The_________function on Series object returns total elements in it including NaNs.

a)

Total()

b)

len()

c)

length()

d)

total()

92.

To specify datatype int16 for a Series object, you can write:

a)

pandas.Series(data=array,dtype=int16)

b)

pandas.Series(data=array,dtype=numpy.int16)

c)

pandas.Series(data=array.dtype=pandas.int16)

d)

All of the above

93.

How to alter the index of Series Sale to weekday names like sun,mon..etc.

a)

Sale.rename(index=['sun','mon','tue','wed','thu','fri','sat'])

b)

Sale.renameindex=['sun','mon','tue','wed','thu','fri','sat']

c)

Sale.index=['sun','mon','tue','wed','thu','fri','sat']

d)

Sale.index(['sun','mon','tue','wed','thu','fri','sat'])