Plotting a referendum - Unemployment
Following the shock decision by the UK to leave the EU, many ideas were put forward as to the reasons behind why so many people voted the ways that they did.
In an effort to learn more about data handling in python, using pandas, matplotlib and other fun stuff I scoured the internet for data and set about plotting graphs.
- Sourcing data
- Mapping data
- Scatter plots
As with the income data, the unemployment data is downloaded from Nomis, and so is already close to how we want it. All that is required is removing some rows which contain invalid data, as well as renaming the columns, before saving as a pickle.
""" Data available from: NOMIS website. Dataset: Claimant count -> Claimant count by sex and age Geography: local authorities: district / unitary (as of April 2015) Date: May 2016 Age: All (16+) Rates: Claimant count AND Claimants as a proportion of residents aged 16-64 Sex: Total Include Area codes Assumes resulting filename is: 'nomis-unemployment.csv' Data is released under the Open Government Licence: http://www.nationalarchives.gov.uk/doc/open-government-licence/ """ import pandas as pd a = pd.read_csv('raw/nomis-unemployment.csv', header=6) a.columns = ['Area','Code','Unemployed','Pct_Unemployed'] a.set_index('Code', inplace=True) a = a.dropna() a.drop('Column Total', inplace=True) a.sort_index(inplace=True) a.to_pickle('./data/unemployment.pkl')
The whole file is also available as a gist.