Page 23 - Informatics_Practices_Fliipbook_Class12
P. 23
output:
Strength of first 3 sections:
A 35
B 50
C 60
dtype: int64
>>> nSections = 3
>>> print("\nStrength of last", nSections, "sections:\n",sections.tail(nSections))
output:
Strength of last 3 sections:
E 45
F 40
G 55
dtype: int64
C T 04 Write Python code to display names and salary of first five employees working in the company.
head(): Returns first n records of the series.
tail(): Returns last n records of the series.
1.5.2 Summarizing a Series
We can obtain a statistical summary of a series (containing numerical values) by using the describe() method. This
summary includes the count of non-null observations, mean, standard deviation, quartiles, minimum, and maximum
values.
>>> sections.describe()
output:
count 7.000000
mean 48.571429
std 8.997354
min 35.000000
25% 42.500000
50% 50.000000
75% 55.000000
max 60.000000
dtype: float64
Note that while the minimum and maximum values in the series are 35 and 60, repectively, the mean value is 48.57.
Further, 25% of the values have an upper limit of 42.5, 50% of the values have an upper limit of 50, 75% of the values
have an upper limit of 55, and the remaining 25% values take value up to the maximum value , i.e. 60. If required, the
values in the above summary may be rounded, as shown below:
>>> # use the default option, round up to one decimal place.
>>> round(sections.describe())
output:
count 7.0
mean 49.0
std 9.0
min 35.0
25% 42.0
50% 50.0
Data Handling using Pandas 9

