MCQ Based On Series
MCQ Based On Series
a. row
b. index
c. row_index
d. Any above option
2. 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
a. 5,1,1,1
b. 5,0,0,0
c. 5,1,5,1
d. 5,5,5,5
4
5. To have output of below python code as shown in figure, identify which attribute can be used to fill in
the blank.
a. loc
b. iloc
c. loc or iloc
d. Neither loc nor loc
7. 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.
5
10. To get the number of dimensions of Series object, _______ attribute is used.
a. size
b. shape
c. itemsize
d. ndim
11. To skip not numeric or null values in series, we can use _________ attribute.
a. skip
b. skipna
c. skipNaN
d. Not possible
12. To get last element of series s1, we may use s1._________ function.
a. tail(1)
b. tail()
c. last[1]
d. last[-1]
13. Identify false statement regarding series data structure of pandas library :
a. Series is homogenous data structure.
b. Series is a two dimensional data structure.
c. Size of series is mutable.
d. Both (b) & (c)
14. 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: l1=[ 1, 2 , 3]
Line 3: l2= list(‘ABC’)
Line 4: S1= p1. series( l1 , rows=l2)
a. Line 4
b. Line 3
c. Line 2
d. Line 1
15. Identify out of below options, which could correct above code in order to help Rohit.
a. In Line-4, Use p1.Series instead of p1.series.
b. In Line-4, Use ‘index’ attribute instead of rows attribute.
c. Both (a) & (b)
d. In Line-1, use import pandas only.
16. 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).
6
a. Aman
b. Both Aman and Riya
c. Neha
d. Riya
7
21. Choose correct option :
Assume there is a series s1 having data elements as 11, 12, and 13 respectively. Programmer ‘Alok’
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.
Index Elements
I False
II False
III True
IV
a. True
Index Elements
III 25
IV 30
b.
Index Elements
II 20
III 25
IV 30
c.
d. None of the above
Index Elements
II 20
b.
8
Index Elements
II True
III True
c.
Index Elements
II 20
III 21
d.
27. 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
9
30. 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)
31 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
32 To get the number of dimensions of a Series object, ___________ attribute is displayed.
1. Index
2. Size
3. Itemsize
4. Ndim
33 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
34 To get the size of the datatype of the items in Series object, you can use ____________ attribute.
a. Index
b. Size
c. Itemsize
d. Ndim
35 To get the number of elements in a Series object, _____________ attribute may be used.
a. Index
b. Size
c. Itemsize
d. Ndim
10
36 To get the number of bytes of the Series data, _____________ attribute is displayed.
a. hasnans
b. nbytes
c. ndim
d. dtype
37 To display third element of a Series object S, you will write__________________.
a. S[:3]
b. S[:2]
c. S[3]
d. S[:2]
38 To display first three elements of a Series object S, you may write____________.
a. S[:3]
b. S[3]
c. S3rd]
d. All of these
39 To display last five rows of a Series object S, You may write_____________.
a. head()
b. head(5)
c. tail()
d. tail(5)
40 Missing data in pandas object is represented through:
a. Null
b. None
c. Missing
d. Nan
41 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))
42 To check if the Series object contains NaN values, ___________ attribute is displayed.
a. hasnans
b. nbytes
c. ndim
d. dtype
43 A __________________ is a pandas data structure that represents a 1-D array like object.
a. Array
b. Numpy
c. Series
d. Dataframe
11
44 You can use numpy._________________ for missing data.
a. NaN
b. Missing
c. None
d. NULL
45 To specify datatype for a Series object, __________________ argument is used.
a. Datatype
b. Type
c. dtype
d. Dtype
46 The _____________ function on Series object returns total elements in it including NaNs.
a. Total()
b. len()
c. length()
d. total()
47 The ________________ function on Series object returns only the count of non-NaN values in it.
a. count()
b. total()
c. length()
d. len()
48 Series is ________________mutable.
a. value size
49 Series is not ________ mutable.
a. Size b. value
50 Given are two objects, a list object namely lst1 and a series object namely ser1, both are having
similar values i.e. 2,4,6,8. Find out the output produced by following statements:
print(lst1*2)
print(ser1*2)
a. [2,4,6,8,2,4,6,8]
1. 4
2. 8
3. 12
4. 16
b. [4,8,12,16]
1 2
2 4
3 6
4 8
5 2
6 4
7 6
8 8
12