Professional Documents
Culture Documents
Series Practice Sheet2
Series Practice Sheet2
Gandhidham Shinay
a) Queue b) Series
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) pd.Series b) pd.Series(NaN)
c) sequence d) ndarray
11. Consider the following Series in Python [1]
data = pd.Series([5, 2, 3, 7], index=['a', 'b', 'c', 'd'])
Which statement will display all odd values?
a) print(data(data%2!=0)) b) print(data[data%2!=0])
1/9
Atmiya Vidyapeeth
12. When an operation is carried out on every value of Series object is called ________. [1]
a) head() b) tell()
c) tail(3) d) tail()
14. To display the second element of Series we can use: [1]
a) s[:1] b) s[:2]
c) s[1] d) s[2]
15. To display third element of a Series object S, you will write ________. [1]
a) S[3] b) S[2]
c) S[:3] d) S[:2]
16. What will be the output of the following code? [1]
import pandas as pd
import numpy
s=pd.Series(data=[31, 54, 34, 89, 12, 23],dtype=numpy.int)
print(s>50)
a) 1 54 b) 0 31
3 89 1 54
dtype: int64 2 34
3 89
4 12
5 23
dtype: bool
c) 1 True d) 0 False
3 True 1 True
dtype: bool 2 False
3 True
4 False
5 False
dtype: bool
17. Find the output of given code: [1]
import pandas as pd
s=pd.Series(['a','s','r'], index=[2,6,9])
print(s>='s')
a) 2 False b) 2 False
2/9
Atmiya Vidyapeeth
6 False 6 True
9 False 9 False
c) 2 True d) 2 False
6 False 6 False
9 True 9 True
18. Write the output of the given code. [1]
import pandas as pd
S1=pd.Series([5, 6, 7, 8, 10], index=['v', 'w', 'x', 'y', 'z'])
l=[2, 6, 1, 4, 6]
S2=pd.Series(l,index=['z', 'y', 'a', 'w', 'v'])
print(S1-S2)
a) a NaN b) v -1.0
v -1.0 w 2.0
w 2.0 y 2.0
x 3.0 z 8.0
y 2.0 dtype: float64
z 8.0
dtype: float64
c) a NaN d) a 0
v -1.0 v -1.0
w 2.0 w 2.0
x NaN x NaN
y 2.0 y 2.0
z 8.0 z 8.0
dtype: float64 dtype: float64
19. Write the output of the following: [1]
import pandas as pd
name=['Raj', 'Ankur', 'Harsh']
p=pd.Series(name, index=[2,5,6])
print(p)
# Reindex the series and create a new series variable
p1=p.reindex([6,2,5])
print (p1)
3/9
Atmiya Vidyapeeth
21. Write a program to print the values of 0, 2, 4 positions from Series s[10,20,30,40,50] using .iloc. [2]
22. Write a program to create an empty series [2]
#import the pandas library and aliasing as pd
23. What do you mean by Series data structure? [2]
24. What is series? Explain with the help of an example. [2]
25. Write a program to create a series from a given Tuple data data=('1', 'Aman', 86.3, 'A'). [2]
26. Write the syntax to sort the series values using indexes in descending order. [2]
27. Give the output: [2]
import pandas as pd
S = pd.Series([10,20,30,40,50], index = ['a', 'e', 'i', 'o', 'u'])
print(S)
# Assigning New Index Values
S.index = [1, 2, 3, 4, 5]
print("Series after new index values")
print(S)
d 225
b 720
a 840
4/9
Atmiya Vidyapeeth
c 650
e 950
import pandas as pd
import numpy as np
data=np.array(['E', 'N', 'V', 'I', 'R', 'O', 'N', 'M', 'E', 'N', 'T'])
a=pd.Series(data)
i. a[: -5]
ii. a [3 : 7]
37. Give the output: [3]
import pandas as pd
s=pd.Series([10,20,30,40,50], index =['a', 'b', 'c', 0, 1])
print(s.loc['a':'c'])
38. Write the output of the following code, considering the Series sr as given below [3]
0 Computer
1 Maths
2 Science
3 English
4 Hindi
5 Social Science
i. print (sr[3 : 5])
ii. print (sr. index)
iii. print (sr. values)
iv. print (sr[0 : 2])
39. Write the output of the following code. [3]
import pandas as pd
import numpy as np
tin=[1, 2, 3, 4, 5]
data1=['a', 'b', 'c', 'd', 'e']
a=pd.Series(data = tin, index=data1, dtype = np.float64)
print(a)
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
5/9
Atmiya Vidyapeeth
c) A is true but R is false. d) A is false but R is true.
43. Assertion (A): empty property: This property returns True if the Series is empty otherwise return False. [1]
Reason (R): empty property of Series does not help to check whether a Series is empty or not?
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
6/9
Atmiya Vidyapeeth
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) nbytes b) hasnans
c) ndim d) dtype
53. To get the number of elements of a Series object. ________ attribute may be used. [1]
a) itemsize b) size
c) index d) ndim
54. To get the number of dimensions of a Series object. ________ attribute is displayed. [1]
a) index b) itemsize
c) size d) ndim
55. To display a series 'S' in descending order select the correct statement; [1]
i. S.sort_values(asc=False)
ii. S.sort(asc=False)
iii. S.sort_values(ascending=False)
iv. S.sort(ascending=False)
7/9
Atmiya Vidyapeeth
(ii) List and tuple can be easily converted into Series by Series() method. [1]
(iii) The data value of series object can be modified using value assignment. [1]
58. Fill in the blanks: [6]
(i) The operation is performed only on the ________ indexes. [1]
(ii) ________ slice operation is used to print whole series. [1]
(iii) if the output is 71. [1]
import pandas as pd
S1 = pd.Series([10, 20, 30, 40, 71,50])
print(S1[ ________ ])
(iv) ________ can be done either in ascending or descending order. [1]
(v) Size of series is ________. [1]
(vi) Series is ________ dimensional array with homogeneous data. [1]
Question No. 59 to 63 are based on the given text. Read the text carefully and answer the questions: [5]
Priyanka, a student of Class XII, has been assigned a code to create a pandas Series 'ST', as shown below.
a 100
b 200
c 300
d 400
e 500
dtype: int64
59. Choose the command that will give the following output.
b 200
c 300
dtype: int64
a) print(S1[2:4]) b) print(S1[1:3])
c) print(S1[:3]) d) print(S1[0:3])
60. Help him to identify the correct statement that can be used to extract the value with the index 'c'.
a) print(S1[c]) b) print(S1(c))
b 200
d 400
dtype: int64
a) print(S1.iloc[2:4]) b) print(S1.iloc[l:4])
8/9
Atmiya Vidyapeeth
c) print(S1.iloc[1:4:2]) d) print(S1.iloc(1:4))
62. Which of the following command will display the series by adding 10 in each value?
a) print(S1)+10 b) print(S1)+print(10)
a) S1=S1.drop('d') b) S1=S1.drop['d']
c) S1=drop('d') d) S1=S1.drop(d)
Question No. 64 to 68 are based on the given text. Read the text carefully and answer the questions: [5]
Priyanka, a student of Class XII, has been assigned a code to create a pandas Series 'ST', as shown below.
a 100
b 200
c 300
d 400
e 500
dtype: int64
64. Choose the command that will give the following output.
b 200
c 300
dtype: int64
65. Help him to identify the correct statement that can be used to extract the value with the index 'c'.
66. Write the command that will give the following output?
b 200
d 400
dtype: int64
67. Write the command that will display the series by adding 10 in each value?
68. Priyanka wants to delete the value against index 'd' Help him to choose the suitable option to do so.
9/9
Atmiya Vidyapeeth