Page 37 - Informatics_Practices_Fliipbook_Class12
P. 37
5. Consider the following two series storing marks and subjects of two different students with roll numbers: 101 and 102:
marks:
101 95
101 89
101 92
102 95
102 90
102 75
dtype: int64
subjects:
101 Math
101 Physics
101 Chemistry
102 Math
102 Chemistry
102 Physics
dtype: object
Write the code snippet for the following queries based on above mentioned series:
(i) Find the highest and lowest marks.
(ii) Determine the subject name(s) with the highest marks obtained in previous part.
(iii) Determine the average marks scored in Math.
(iv) Find the number of subjects in which the student scored above 90.
(v) Find the subjects in which the student scored below 90.
(vi) Find the average marks scored by student with roll number 101.
Case-based Questions
Suppose the teacher-in charge of class XII wishes to determine top 5 scorers in the Arts subject. She has access to the
following Pandas Series representing the scores of ten students in arts subjects :
artScores = pd.Series([85, 92, 78, 89, 95, 87, 93, 91, 84, 88])
Help the teacher-in charge by writing a Python code snippet to extract the scores of the top 5 students using indexing and
slicing.
Previous Years' Questions
1. Write a Python program to create a series object, country using a list that stores the capital of each country. [2023]
Assume four countries to be used as index of the series object are India, UK, Denmark, and Thailand having their capitals
as New Delhi, London, Copenhagen, and Bangkok respectively.
Ans. import pandas as pd
l=['New Delhi', 'London', 'Copenhagen','Bangkok']
country=pd.Series(['New Delhi', 'London', 'Copenhagen','Bangkok'],
index=['India', 'UK', 'Denmark','Thailand'])
print(country)
Data Handling using Pandas 23

