You are on page 1of 4

Series

1 You can use numpy _________________ for missing data.


Ans: NaN.
2 ______ Pandas object cannot grow in size.
(a)DataFrame (b)Series
(c)Panel (d)None of these
Ans: (b) Series
3 Given a Pandas series called Sequences, the command which will display the last
7 rows is __________________.
(i) print(Sequences.tail(7))
(ii) print(Sequences.Tail(7))
(iii) print(Sequences.last(7))
(iv) print(Sequences.Last(7))
Ans:(i)
4 To get the number of bytes of the Series data, _______ attribute is used.
(a)hasnans (b)nbytes
(c)ndim (d)dtype
Ans:(b) nbytes.
5 Consider the following series named ‘animal’:

T Tiger
L Lion
W Wolf
E Elephant
F Fox
dtype: object

Write the output of the command:


print(animal[: : -2])
Ans: Fox, Wolf, Tiger
6 Which of the following statement will import Pandas library?
(a)import panda as pd (b)import pandas as pd
(c)import Pandas as pd (d)all of these
Ans: (b)
7 Write the output of the given command:
import pandas as pd
s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F'])
print(s[s%2==1])

Output:

8 Write the output:


import pandas as pd
a=pd.Series(data=[9,10,11])
b=pd.Series(data=a*2)
print(b)
Output:

9 Write a program to create a Series object using a dictionary that stores the
number of peoples in each states (any 4 states)
Ans: import pandas as pd
a = {‘Assam’:5000, ‘Nagaland’:6000, ‘Manipur’:4000, ‘Maharashtra’:8000}
b = pd.Series(a)
print(b)
10 Given a Series object s4. Write a program to change the values at its 3rd row
(index 2) and 4th row to 8700.
11 What will be the output for the following code?
import pandas as pd
import numpy as np
s=pd.Series(np.random.randn(3))
print(s.ndim)
(a)0 (b)1
(c)2 (d)3
Ans:(b) 1
12 Assuming the given series named ‘S1’, which command will be used to print 4 as
output?
Romit 87

Suresh 54

Sakshi 88

Madhu 44

Name: Student, dtype: int64

(a)S1.index (b)S1.size
(c)S1.values (d)S1.ndim
13 Given the following series objects:
S1 S2
0 10 0 1
1 15 2 2
2 20 3 3
4 25 4 4
5 30 6 5
What will be the result of S1–S2?
14 To create an empty Series object, you can use:
(a) pd.Series(empty) (b) pd.Series(np.NaN)
(c) pd.Series( ) (d) all of these
Ans: (c) pd.Series()
15 Write a program to create a Series object using an ndarray that has 10 elements
in the range 15 to 50.
Ans: import pandas as pd
import numpy as np
a = pd.Series(np.linspace(15,50,10))
print(a)
16

17

18

19 Consider the Series S1:


A 6700
B 5600
C 5000
D 5200
E 4000

What will be the output of the following commands:


(a)print(S1>5000)
(b)print(S1.sort_values( ))
(c)print(S1 * 2)
20 Write a program to create data series (with 4 values) and then change the
indexes of the series object in any random order.

You might also like