Question
1.
Create
a
table
called
b_pop
that
has
two
columns
labeled
time
and
population_total
. The first column should contain the years from 1970 through 2015 (includ-
ing both 1970 and 2015) and the second should contain the population of Bangladesh in each of
those years.
In [107]:
b_pop
=
population
.
where(
'
geo
'
, are
.
equal_to(
'
bgd
'
))
.
where(
'
time
'
, are
.
above_or_equal
b_pop
Out[107]:
time | population_total
1970 | 65048701
1971 | 66417450
1972 | 67578486
1973 | 68658472
1974 | 69837960
1975 | 71247153
1976 | 72930206
1977 | 74848466
1978 | 76948378
1979 | 79141947
... (36 rows omitted)
In [108]:
_
=
ok
.
grade(
'
q1_1
'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 3
Failed: 0
[ooooooooook] 100.0% passed
3

Run the following cell to create a table called
b_five
that has the population of Bangladesh
every five years.
At a glance, it appears that the population of Bangladesh has been growing
quickly indeed!
In [109]:
b_pop
.
set_format(
'
population_total
'
, NumberFormatter)
fives
=
np
.
arange(
1970
,
2016
,
5
)
# 1970, 1975, 1980, ...
b_five
=
b_pop
.
sort(
'
time
'
)
.
where(
'
time
'
, are
.
contained_in(fives))
b_five
Out[109]:
time | population_total
1970 | 65,048,701
1975 | 71,247,153
1980 | 81,364,176
1985 | 93,015,182
1990 | 105,983,136
1995 | 118,427,768
2000 | 131,280,739
2005 | 142,929,979
2010 | 151,616,777
2015 | 160,995,642
Question 2.
Create a table called
b_five_growth
that includes three columns,
time
,
population_total
, and
annual_growth
. There should be one row for every five years from 1970
through 2010 (but not 2015). The first two columns are the same as
b_five
. The third column is
the
annual
growth rate for each five-year period. For example, the annual growth rate for 1975 is
the yearly exponential growth rate that describes the total growth from 1975 to 1980 when applied
5 times. (Consult the
Growth Rates
example in the textbook to help understand how to compute
the
annual
growth rate)
Hint
: Only your
b_five_growth
table will be scored for correctness; the other names are sug-
gestions that you are welcome to use, change, or delete.
Hint
: You may find the
exclude
method to be helpful (
Docs
).
In [110]:
b_1970_through_2010
=
b_five
.
exclude(
-1
)
initial
=
b_1970_through_2010
.
column(
1
)
changed
=
b_five
.
exclude(
0
)
.
column(
1
)
b_five_growth
=
b_1970_through_2010
.
with_column(
'
annual_growth
'
, ((changed
/
initial)
**
b_five_growth
.
set_format(
'
annual_growth
'
, PercentFormatter)
Out[110]:
time | population_total | annual_growth
1970 | 65,048,701
| 1.84%
1975 | 71,247,153
| 2.69%
1980 | 81,364,176
| 2.71%
1985 | 93,015,182
| 2.64%
1990 | 105,983,136
| 2.25%
1995 | 118,427,768
| 2.08%
2000 | 131,280,739
| 1.71%
2005 | 142,929,979
| 1.19%
2010 | 151,616,777
| 1.21%
4

In [111]:
_
=
ok
.
grade(
'
q1_2
'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 4
Failed: 0
[ooooooooook] 100.0% passed
While the population has grown every five years since 1970, the annual growth rate decreased
dramatically from 1985 to 2005. Let’s look at some other information in order to develop a possible
explanation. Run the next cell to load three additional tables of measurements about countries
over time.
In [112]:
life_expectancy
=
Table
.
read_table(
'
life_expectancy.csv
'
)
child_mortality
=
Table
.
read_table(
'
child_mortality.csv
'
)
.
relabeled(
2
,
'
child_mortali
fertility
=
Table
.
read_table(
'
fertility.csv
'
)
In [113]:
life_expectancy
Out[113]:
geo
| time | life_expectancy_years
afg
| 1800 | 28.21
afg
| 1801 | 28.2
afg
| 1802 | 28.19
afg
| 1803 | 28.18
afg
| 1804 | 28.17
afg
| 1805 | 28.16
afg
| 1806 | 28.15
afg
| 1807 | 28.14
afg
| 1808 | 28.13
afg
| 1809 | 28.12
... (43847 rows omitted)
The
life_expectancy
table contains a statistic that is often used to measure how long people
live, called
life expectancy at birth
. This number, for a country in a given year,
does not measure
how long babies born in that year are expected to live
. Instead, it measures how long someone
would live, on average, if the
mortality conditions
in that year persisted throughout their lifetime.

#### You've reached the end of your free preview.

Want to read all 27 pages?

- Fall '17
- Demography, World population