Global incomes: Dispersion
A quantile is a measure of dispersion created by dividing a frequency distribution of a DataFrame into even groups. You can return values at the given quantile q
of a DataFrame df
with the command df.quantile(q)
; likewise, supplying a list as q
will return a value for each given quantile.
Here, you will continue your analysis of global income distribution using two measures of dispersion: the standard deviation, or square root of variance, and the interquartile range (IQR).
pandas
has been imported as pd
, and the income
DataFrame from the previous exercise is in your workspace.
Este exercício faz parte do curso
Importing and Managing Financial Data in Python
Instruções do exercício
- Using the appropriate functions, calculate the mean of income per capita as
mean
and the standard deviation asstd
. - Without using
.quantile()
, calculate and print the upper and lower bounds of an interval of one standard deviation around the mean in a listbounds
:- subtract
std
frommean
as the first element - add
std
tomean
as the second element
- subtract
- Using
.quantile()
and a list of two appropriate decimal values, calculate and print the first and the third quartile of'Income per Capita'
asquantiles
. Do the values match? - Calculate and print the IQR,
iqr
, using the simple subtraction expression you learned in the video.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Calculate mean
mean = ____
# Calculate standard deviation
std = income['Income per Capita'].std()
# Calculate and print lower and upper bounds
bounds = [____, ____]
print(bounds)
# Calculate and print first and third quartiles
quantiles = income['Income per Capita'].____([____, ____])
print(quantiles)
# Calculate and print IQR
iqr = ____ - ____
print(iqr)