Research question: Do more developed nations have a higher percentage of the population above the age of 65 and is this number increasing around the world?

In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import folium
In [2]:
#import the dataset
csv = pd.read_csv('./Indicators.csv')
csv.head()
Out[2]:
CountryName CountryCode IndicatorName IndicatorCode Year Value
0 Arab World ARB Adolescent fertility rate (births per 1,000 wo... SP.ADO.TFRT 1960 1.335609e+02
1 Arab World ARB Age dependency ratio (% of working-age populat... SP.POP.DPND 1960 8.779760e+01
2 Arab World ARB Age dependency ratio, old (% of working-age po... SP.POP.DPND.OL 1960 6.634579e+00
3 Arab World ARB Age dependency ratio, young (% of working-age ... SP.POP.DPND.YG 1960 8.102333e+01
4 Arab World ARB Arms exports (SIPRI trend indicator values) MS.MIL.XPRT.KD 1960 3.000000e+06
In [3]:
# filter on topic
mask = csv['IndicatorName'].str.contains('Population ages 65 and above')
data = csv[mask]
print data.head()
print data['Year'].max()
                                 CountryName CountryCode  \
67                                Arab World         ARB   
146                   Caribbean small states         CSS   
216           Central Europe and the Baltics         CEB   
336  East Asia & Pacific (all income levels)         EAS   
457    East Asia & Pacific (developing only)         EAP   

                                 IndicatorName      IndicatorCode  Year  \
67   Population ages 65 and above (% of total)  SP.POP.65UP.TO.ZS  1960   
146  Population ages 65 and above (% of total)  SP.POP.65UP.TO.ZS  1960   
216  Population ages 65 and above (% of total)  SP.POP.65UP.TO.ZS  1960   
336  Population ages 65 and above (% of total)  SP.POP.65UP.TO.ZS  1960   
457  Population ages 65 and above (% of total)  SP.POP.65UP.TO.ZS  1960   

        Value  
67   3.535465  
146  4.141187  
216  7.207827  
336  3.878393  
457  3.631579  
2014
In [4]:
# Filter on year and prepare the dataset
data1 = data[data['Year'] == 2014]
data1 = data[['CountryCode', 'Value']]
data1.head()
Out[4]:
CountryCode Value
67 ARB 3.535465
146 CSS 4.141187
216 CEB 7.207827
336 EAS 3.878393
457 EAP 3.631579
In [11]:
#make the geo graph
world_geo = r"./world.json"
maps = folium.Map(location=[50, 0], zoom_start=1.5)
In [12]:
maps.choropleth(geo_data=world_geo, data=data1, columns=['CountryCode', 'Value'], 
                key_on="feature.id", fill_color='YlGn', line_opacity=0.2, 
                fill_opacity=0.7, legend_name="The percentage of the population above 65")
In [13]:
maps
Out[13]:
In [ ]:
maps.save('population.html')

Now if there is an increas

In [14]:
#data['Year'].value_counts()
numbers = []
# This will find the mean of every year
for values in data['Year'].unique():
    year = data[data['Year'] == values]
    mean = year['Value'].mean()
    numbers.append(mean)
In [15]:
print numbers
[4.805527235699834, 4.830881180406925, 4.851963460130619, 4.86930206668389, 4.883653688106582, 4.896365046991207, 4.953978770667422, 5.01034695881764, 5.066217018450104, 5.121299271255699, 5.175605715993127, 5.2495516481908036, 5.315730939030148, 5.376345143322391, 5.433882286629776, 5.489265228604536, 5.567416598257148, 5.642733308971166, 5.709221702432483, 5.7558497412361, 5.777556491001298, 5.796759970658805, 5.790580197072674, 5.772400738393211, 5.760508579967103, 5.765607731438798, 5.80942599633237, 5.865837801293526, 5.931892179565349, 6.00217071231435, 6.071663531105269, 6.162955455386512, 6.2542727260326805, 6.342602404302445, 6.425186223605827, 6.500119844798511, 6.591896619562163, 6.673498794696561, 6.749395548604461, 6.824969475459089, 6.903472718278217, 7.003838352132395, 7.105148021859255, 7.203808525021032, 7.292490932497896, 7.367857960811386, 7.451058220981131, 7.524332436823211, 7.5948154975450635, 7.673484939572372, 7.7633813034369625, 7.8805373532593075, 8.004537583295999, 8.140807538515467, 8.289291364967639]
In [18]:
#Make the graph
plt.plot(data['Year'].unique(), numbers)
plt.title('Year vs the % of the population above 65')
plt.xlabel('Years')
plt.ylabel('Percentage of people above 65')
plt.axis([1960,2014,0,9])
plt.savefig('graph.png', bbox_inches='tight')
000webhost logo