Page 40 - Informatics_Practices_Fliipbook_Class12
P. 40
10. Consider the following series: [2022]
ser=pd.Series (['C', 'O', 'M', 'F', 'O', 'R', 'T', 'A', 'B', 'L', 'E'],
1ndex=[l, 2, 3, 4, 5, 6, 7, 8, 9, 10, ll])
print (ser [4 :])
(a) (b) (c) (d)
4 F 4 F 4 F 5 O
5 O 5 O 5 O 6 R
6 R 6 R 6 R 7 T
7 T 7 T 7 T 8 A
8 A 8 A 8 A 9 B
9 B dtype: object 9 B 10 L
10 L dtype: object 11 E
11 E dtype: object
dtype: object
Ans. (d)
5 O
6 R
7 T
8 A
9 B
10 L
11 E
dtype: object
NCERT Exercise Solutions
1. What do you understand by the size of a Series?
Ans. Size attribute gives the number of elements present in Series.
2. Create the following Series and do the specified operations:
a. EngAlph, having 26 elements with the alphabets as values and default index values.
b. Vowels, having 5 elements with index labels 'a', 'e', 'i', 'o' and 'u' and all the five values set to zero. Check if it is an empty
series.
c. Friends, from a dictionary having roll numbers of five of your friends as data and their first name as keys.
d. MTseries, an empty Series. Check if it is an empty series.
e. MonthDays, from a numpy array having the number of days in the 12 months of a year. The labels should be the month
numbers from 1 to 12.
Ans. a. import pandas as pd
EngAlph = pd.Series(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
print(EngAlph)
b. import pandas as pd
vow = pd.Series(0,index=['a','e','i','o','u'])
print(vow)
26 Touchpad Informatics Practices-XII

