Pandas Series Worksheet1
Pandas Series Worksheet1
5. Create a series S with the following list L : [5,10,15,20,25]. Write a statement to assign the
series as a,b,c,d,e index explicitly
i. Create the series S.
ii. Display the values which are greater than or equal to 20.
iii. Display the values 15 and 20 using iloc .
iv. Display the values 10 and 15 using loc.
v. delete the value 15 from the series S.
6. Write a program to display which sections made a contribution more than Rs.5500/-
.Series Object s11 stores the charity contribution made by each section.
A 6700
B 5600
C 5000
D 52
7. Given the following Series P1 stores the marks made by each section:
P1
a 95
b 90
c 75
d 80
Write the command to display the sections made a mark greater than 90
Page 1 of 3
8. Consider a given Series , SR:
a 50
b 40
c 55
d 45
1. Write command in Python Pandas to update the index to E,F,G,H
2. Write command to delete the first element.
9. Write output for the given python code:
import pandas as pd
L1=[10,20,30,40,50]
S1=pd.Series([10,20,30,40,50])
S2=pd.Series(25,index=[0,1,2,3,4])
S3=S1*S2
print("L1*2=",L1*2)
print("S1*2=",S1*2)
print("S1*S2=",S3)
10. Given are two objects, a list object namely lst1 and a Series object namely A, both are
having similar values i.e. 2, 4, 6, 8,10. Mr. Singh is trying to run the following commands. Will
these commands run successfully or not. Justify your answer.
a. print(lst1**2)
b. print(A**2)
11. Answer the following based on the series given below.
import pandas as pd
list1=[1,2,3,4,5,6,7,8]
list2=['swimming','tt','skating','kho kho', 'bb', 'chess', 'football',"cricket"]
school=pd.Series(list1,index=list2)
school.name=("little")
print (school*2) #statement 1
print (school.tail(3)) # statement 2
print (school["tt"]) # statement 3
print (school[2:4]) # statement 4
Page 3 of 3