0% found this document useful (0 votes)
26 views4 pages

PANDAS SERIES - WS4 New

This document is a worksheet for Class XII students at M.E.S Indian School, Doha, focusing on data handling using the Pandas library in Python. It contains a series of coding exercises and questions related to creating and manipulating Pandas Series, including tasks that require debugging and completing code snippets. The worksheet aims to enhance students' understanding of data handling concepts in Python.

Uploaded by

rizafatin07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

PANDAS SERIES - WS4 New

This document is a worksheet for Class XII students at M.E.S Indian School, Doha, focusing on data handling using the Pandas library in Python. It contains a series of coding exercises and questions related to creating and manipulating Pandas Series, including tasks that require debugging and completing code snippets. The worksheet aims to enhance students' understanding of data handling concepts in Python.

Uploaded by

rizafatin07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

M.E.

S INDIAN SCHOOL, DOHA - QATAR


Worksheet 4 2025 - 2026

Section : BOYS’/GIRLS Date : 25/03/25


Class & Div. : XII (ALL DIVISIONS) Subject: IP

Lesson / Topic: Data Handling using Pandas – I (SERIES)


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

1. Based on the Series S1 given below. What will be an output of the code?

(a) print(S1[ S1 > 55 ])


(b) print(S1[ 0 : 4 ] )

2. Complete the given Python code to make a series and get the required output (ignore the dtype attribute):
Physics 78
Accountancy 50
Biology 34
IP 40

import ____________ pd
data=[78,50,34,40]
subject =["Physics","___________","Humanities","_________"]
S=pd.Series(data, index=_________)
print(__________)

3. Find the output of the following code:


import pandas as pd
lst1=[20,35,40]
ser1=pd.Series([20,35,40])
print(lst1+ lst1)
print(ser1+ser1)

4. The Python code written below has syntactical errors. Rewrite the complete code and underline the
correction(s) made.
import Pandas as pd
stud=[‘Name’:’Ramya’,’Class’:11,’House’:’Red’]
s=p.Series(s)
print(s)

5. Complete the given Python code to get the required output as "California":
import _____________ as pd
data = {'Yosemite': 'California', 'Yellowstone': 'Wyoming', 'Glacier': 'Montana', 'Rocky Mountain': 'Colorado'}
national_parks = pd.Series(_____________)
print(national_parks_____________)

F 061, Rev 01, dtd 10th March 2020 1


6. Consider the commands below:
import pandas as pd
lst=[10,20]
ds=pd.Series([10,20])

Here lst is a list and ds is a series. What will be the output of the following
commands? Justify your answer.
a) print (lst * 2)
b) print ( ds * 2 )

7. Write a Python program to store the marks of 5 students in a dictionary where the keys are student names
and values are their respective marks. Convert this dictionary into a Pandas Series and identify which students
scored more than 80 marks.

8. What will be the output of the following code:


import pandas as pd
list1=[2,4,6,8]
list2=['gh','mn','pq','st']
school=pd.Series(list1,index=list2)
print (school*2)
print (school[1:3])

9. What will be the output of the following Python code?


import pandas as pd
dd={'One':1,'Two':2,'Three':3,'Seven':7}
rr=pd.Series(dd)
rr['Four']=4
print(rr)

10.Find the output:


import pandas as pd
data = pd.Series([10, 20, 30, 40, 50], index=['A', 'B', 'C', 'D', 'E'])
other_data = pd.Series([15, 25, 35, 45, 55], index=['A', 'B', 'C', 'D', 'E'])
print(data > other_data)

11.Write the output


import pandas as pd1
s = pd1.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print (s.head(4))

12. Write the output


import pandas as pd1
s = pd1.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print (s[-3:])

13. What will be the output of the following code?


import pandas as pd
s = pd.Series(6,index=range(0,5))
print(s)

14. Write the output of following series.


import pandas as pd1
s = pd1.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print (s[['c','d']])

F 061, Rev 01, dtd 10th March 2020 2


15. Write the output :
import pandas as pd
s1 = pd.Series([11,12,13,14], index=[1,2,3,4])
s2 = pd.Series([21,22,23,24], index=[1,2,3,4])
s3 = pd.Series([31,32,33,34], index=[101,102,103,104])
print(s1+s2)
print(s1*s2)
print(s2/s1)
print(s2-s1)
print(s1+s3)

16 . L is a list whereas S is a Series. Both have values 5, 10,15.


What will be the output of the following
a. print (L*2)
b. print(S*2)

17. Predict the output of the following code.


data = {'one':'a','two':'b','three':'c'}
s=pd.Series(data)
print(s)
print(s.size)

18. Predict the output of the following code


import pandas as pd
import numpy as np
value = np.arange(10, 15, 1)
s=pd.Series(data = value*4, index=value)
print(s)

19. Predict the output of the following code.


import pandas as pd
data = {'one':'a','two':'b','three':'c'}
s=pd.Series(data)
print(s)
s.index=1,2,3
s[1,3]=100
print(s)
print(s[[1,3]])

20. Write output of the given code:


import pandas as pd
data=[10,11,25,26,30,33]
s=pd.Series(data,index=[1,2,3,4,5,6])
print(s%5==0)
print(s[s>3])

21. Write output of the given code:


import pandas as pd
S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'],
index=['India', 'USA', 'UK', 'France'])
print(S1)
print(S1[0::2])

22. Write output of the given code:


import pandas as pd
l=[20,40,90,110]
S1 = pd.Series([20,40,90,110])
print(l*2)
print(S1*2)

F 061, Rev 01, dtd 10th March 2020 3


23. Give the output:
import pandas as pd
x=pd. Series ([10,20,30,40,50], index = [1,2,3,4,5])
print (x. loc [2])
print (x. iloc [2])
print (x [2])
print (x. drop (2))

24.Give the output:


import pandas as pd
s= pd. Series ([10,20,30,40,50,60,70,80], index= [‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’])
print (s [2:5])
print (s [‘b’: ‘f’: 2])

25. Write a program to create a Series to print scalar value “5” four times.

26.Write a program to convert the given dictionary to a Pandas series.


D = {'a': 100, 'b': 200, 'c':300, 'd':400, 'e':800}

27. Create the following series Student which has the name and marks secured by 5 students.
Arun 96.5
Amal 58.0
Gunal 77.5
Karthick NaN
Kumar 87.5

28. Write the code to create a series s1 with values 10,50,78,35,67,89 and do the following.
a)Change the index to a,b,c,d,e,f,g
b)Name the attribute which gives the no. of elements.
c)Display the second,third and fourth elements
d) Display first five elements

29. Write a program in Python to create series of vowels (Name of the Series as VOWEL).

30. Ananya wants to store her Term-I marks in a Series which is already stored in a NumPy array.
Write the code which will create the series with Subjects as indexes and Marks as elements.

***************************************THE END *******************************************

F 061, Rev 01, dtd 10th March 2020 4

You might also like