Series Worksheet
Series Worksheet
Questions Solutions
Q.1- Given the following Series1
A 100
B 200
C 300
D 400
E 500
Write the command to create above Series and then double the value in series and store
in another series named Series2
QTR1 50000
QTR2 65890
QTR3 56780
QTR4 89000
QTR5 77900
Write a program in Python Pandas to create and display the series.
Q.6- What will be the output produced by the following programming statements 1 & 2?
import pandas as pd S1=pd.Series(data=[31,41,51]) print(S1>40) -->Statement1
print(S1[S1>40]) -->Statement2
Q.19- Create a Series object S1 using a python sequence [2,4,6,8] and default indices.
Q.20- Write the output of the following code fragment. import pandas as pd
s2=pd.Series(["i","am", "a","student"]) print(s2)
Q.21- Write the output of the following code fragment. import pandas as pd
s1=pd.Series(200,index=range(2,13,2))
print(s1)
Q.22- Write the output of the following code fragment. import pandas as pd
s1=pd.Series(range(2,11,2), index=[x for x in "abcde"])
print(s1)
Q.23- Write the output of the following code fragment. import pandas as pd
import numpy as np x=np.arange(10,15) s3=pd.Series(index=x, data=x*2)
s4=pd.Series(x**2,x)
print(s3) print(s4)
Q.24- Sequences section and contribution store the section name ( 'A','B','C','D','E') and contribution
(8900,8700,7800,6500,nil) for charity. Your school has decided to donate more contribution by
each section, so donation has been doubled.
Write code to create series object that stores the contribution amount as the values and section
name as indexes with data type as float32.
Q.25- Write the output of the following code fragment. import pandas as pd
import numpy as np val1=np.arange(5.25,50,10.25) ser1=pd.Series(val1,index=['a','b','a','a','b'])
print(ser1)
print(ser1['a'])
print(ser1['b'])
Q.26- Consider a series object s10 that stores the number of students in each section of class 12 as
shown below. First two sections have been given task for selling tickets @ Rs.100/- per ticket
as a part of social experiment. Write code to create the series and display how much section A
and B have collected.
A 39
B 31
C 32
D 34
E 35