In [1]:
%matplotlib inline
import pandas as pd
from pandas import DataFrame
import pickle
import folium
from IPython import display
In [2]:
df = pd.read_pickle('.././data/pickle/pypf_prep.pkl')
regionlookup = pd.read_csv('.././data/maps/oldnewlookupregions.csv', names=['GOR10CD', 'Area_code', 'Region'])
regionlookup['Region'] = regionlookup['Region'].str.upper()
regionlookup['Region'] = regionlookup['Region'].str.strip()
regionlookup['Region'] = regionlookup['Region'].str.replace('EAST OF ENGLAND', 'EAST')
#or_geo = '.././data/maps/gor.json'
In [3]:
maps = {}
for cause in df.Cause.unique():
grp = df[(df['Cause'] == cause) & (df['Sex'] == 'Male')].groupby('Region')['Rate per 100,000 (standardised)'].mean()
grp = DataFrame(grp).reset_index()
maps[cause] = pd.merge(grp, regionlookup, on='Region')
In [4]:
maps['All Mesothelioma']
Out[4]:
In [5]:
maps['IPF'].describe()
Out[5]:
In [6]:
map = folium.Map(location=[54.2, -2.45], zoom_start=5)
map.geo_json(geo_path='gor.json', data_out='GorIPF.json', data=maps['IPF'],
columns=['GOR10CD', 'Rate per 100,000 (standardised)'],
key_on='feature.properties.GOR10CD',
threshold_scale=[11, 12, 13, 14, 15],
fill_color='PuBu', fill_opacity=0.7, line_opacity=0.3,
legend_name='Male IPF deaths by region per 100,000 population (1975-2012)')
map.create_map(path='IPF_death_per100000.html')
map = folium.Map(location=[54.2, -2.45], zoom_start=5)
map.geo_json(geo_path='gor.json', data_out='GorMES.json', data=maps['All Mesothelioma'],
columns=['GOR10CD', 'Rate per 100,000 (standardised)'],
key_on='feature.properties.GOR10CD',
#%%! threshold_scale=[6, 7, 8, 9, 10, 16],
fill_color='PuBu', fill_opacity=0.7, line_opacity=0.3,
legend_name='Male Mesothelioma deaths by region per 100,000 population (1975-2012)')
map.create_map(path='Mesothelioma_death_per100000.html')
map = folium.Map(location=[54.2, -2.45], zoom_start=5)
map.geo_json(geo_path='gor.json', data_out='GorASB.json', data=maps['Asbestosis'],
columns=['GOR10CD', 'Rate per 100,000 (standardised)'],
key_on='feature.properties.GOR10CD',
# threshold_scale=[11, 12, 13, 14, 15],
fill_color='PuBu', fill_opacity=0.7, line_opacity=0.3,
legend_name='Male Asbestosis deaths by region per 100,000 population (1975-2012)')
map.create_map(path='Asbestosis_death_per100000.html')
In [7]:
display.IFrame('IPF_death_per100000.html', '100%', 500)
Out[7]:
In [8]:
display.IFrame('Mesothelioma_death_per100000.html', '100%', 500)
Out[8]:
In [9]:
display.IFrame('Asbestosis_death_per100000.html', '100%', 500)
Out[9]:
In [ ]:
In [ ]: