Series 1
Series 1
Q1 Create a Series named as weather that is used to store temperature of different cities.
Here city name is taken as the index
Delhi 35
Mumbai 45
Chennai 48
Goa 42
Q2 Create a numpy array that store information about the total sales of every month. Now store this
data in a Series , Sales in which month name is taken as index and total sales in each month is
taken as value. Take Month from Jan to May only
Q3 Create a dictionary that contains subject code and teacher name. In this dictionary subject code is
taken as key and teacher name is taken as value. Now store this dictionary in a series and also
display the teacher name whose subject code is given by user.
Q5 Create the given series “Alpha” that contains information about the number of Admissions of
“Alpha Academy” in each year from 2015.
15 20
16 35
17 30
18 42
19 44
20 35
Perform the following operations
a) Change the index values as [2015,2016,2017,2018,2019,2020]
b) Set the Name of the index as “Years”
c) Display the data from year 2016 to 2019
d) Display the data of year 2016, 2018 and 2020.
e) Display the details of those year where number of admission is more than equal to 40.
f) Display the number of entries in the Series.
g) Change the number of admission of year 2017 as 41
h) Display the year with maximum number of admission and minimum number of admissions
also.
i) Display the total number of admission from year 2016 to 2018.
Q6 Create a Series named as Vowels, having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ and all
the five values set to zero.
a) Check if it is an empty series
b) Set all the values of Vowels to 10 and display the Series.
c) Divide all values of Vowels by 2 and display the Series
d) Create another series Vowels1 having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’
having values [2,5,6,3,8] respectively.
e) Add Vowels and Vowels1 and assign the result to Vowels3.
f) Alter the index labels of Vowels1 to [‘A’, ‘E’, ‘I’, ‘O’, ‘U’].
Q8 Create the series given below in which four zone of an Area is taken as index and number of voters
in that area is taken as values
North 200
South 500
East 350
West 420
a) Set the name of the index as “ZONE”
b) Set the name of the series as “Voting Data”
c) Display the voting zone where number of voters are more than 400.
d) Display total number of voters from all zones.
e) Display the Zone with maximum and minimum voters.
f) Display the 75% of total number of Voters from each zone.
Q9 Create a pandas Series using an nd array that has 5 elements in the range 24 to 64.
Q10 Create a Series using a dictionary that stores the number of students in Science, Commerce and
Humanity Stream.
Q11 Create a Series named as Budget that stores the initial budget allocated (50000/- each) for the four
quarters of the year : Qtr1, Qtr2, Qtr3, Qtr4
Q12 Consider the Series “Shares” that stores the share value of each group
A 6700
B 5600
C 5000
D 5200
Write code to modify the amount of Group A as 7600 and for Group C and D as 7000. Display the
modified Series.
SeriesA SeriesB
10 500 10 800
20 450 20 600
30 600 30 200
40 300 40 100
a) A=SeriesA + SeriesB
b) B=SeriesA *5 c) C=(SeriesA//100)**2
To display last five rows of a series object ‘S’, you may write:
i. S.Head() ii. S.Tail(5) iii. S.Head(5) iv. S.tail()
Q17 Which of the following command will show the last 3 rows from a Pandas Series named NP?
i. NP.Tail( ) ii. NP.tail(3) iii. NP.TAIL(3) iv. All of the above
Q18 In Python Pandas, while performing mathematical operations on series, index matching is
implemented and all missing values are filled in with _____by default.
i. Null ii. Blank iii. NaN iv. Zero
Q19 Assertion (A):- To use the Pandas library in a Python program, one must import it.
Reasoning (R): - The only alias name that can be used with the Pandas library is pd.
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
a 100
b 200
c 300
d 400
e 500
dtype: int64
With reference to the above, answer the given questions:
i. Choose the command that will give the following output:
b 200
c 300
dtype: int64
ii. 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)) c. print('S1' ['c']) d. print(S1 ['c'])
iii Which of the following command will give the following output:
b 200
d 400
dtype: int64
a. print(S1.iloc[1:4]) b. print(S1.iloc[2:4]) c. print(S1.iloc(1:4)) d.
print(S1.iloc[1:4:2])
iv. Which of the following command will display the series by adding 10 in eachvalue.
a. print(S1 [+10]) b. print(S1+10) c. print(S1)+10 d. print(S1)+print(10)
v. Pushp wants to delete the value against index 'd'. Help him to choose the suitable option to do
so:
a. S1=S1.drop(d) b. S1=S1.drop('d') c. S1=drop('d') d. S1=S1.drop['d']
Q23
Q24 Find the output
a) import pandas as pd
import numpy as np
s=pd.Series(np.arange(5,20,6), index=[x for x in np.arange(20,100,30)])
print(s)
b) import pandas as pd
d={'Ravi':[50,80,75],'Shyam':[60,80,'Ab'],'Kapil':[80,75,92]}
stud=pd.Series(d, index=['Shyam','Kapil','Ravi'])
print(stud)
c)
import pandas as pd
s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F'])
print(s[s%2==0])
d)
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)
e)
Consider the Series “Data” given below
a 10
b 11
c 12
d 13
e 14
f 15
Write output after execution of following statements
Data[1:3]=30
Data[‘c’:’e’]=100
print(Data)
f)
Consider the following series named animal:
L Lion
B Bear
E Elephant
T Tiger
W Wolf
dtype:object
Write output of the following:
a) print(animal([::-3]) b) print(animal([‘L’:’T’])