Skip to content

Instantly share code, notes, and snippets.

View jblumenau's full-sized avatar

Jack Blumenau jblumenau

View GitHub Profile
@jblumenau
jblumenau / twfy_pd_lookup_1979_2019.csv
Created April 15, 2019 15:55
TheyWorkForYou to UK Parliament data platform lookup table (1979 to 2019)
twfy_person_id name mnis_person_id
10001 Diane Abbott 172
10003 Irene Adams 631
10004 Nick Ainger 537
10005 Bob Ainsworth 306
10006 Peter Ainsworth 99
10007 Richard Allan 397
10008 Graham Allen 364
10009 David Amess 44
10010 Michael Ancram 259
@jblumenau
jblumenau / party_constituency_vote_shares_may_19.csv
Created June 12, 2017 16:47
party_constituency_vote_shares_may_19
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
"","code","constituency","Con","Lab","LD","UKIP","Green","SNP","PC","Other","Con_hi","Lab_hi","LD_hi","UKIP_hi","Green_hi","SNP_hi","PC_hi","Other_hi","Con_lo","Lab_lo","LD_lo","UKIP_lo","Green_lo","SNP_lo","PC_lo","Other_lo"
"1","E14000530","Aldershot","55.0","25.5","12.3","4.7","2.5","0.0","0.0","0.0","61.3","32.8","17.1","7.1","4.3","0.0","0.0","0.0","48.7","19.4","8.8","2.7","1.4","0.0","0.0","0.0"
"2","E14000531","Aldridge-Brownhills","62.8","26.8","5.4","0.0","0.0","0.0","0.0","5.0","68.2","31.9","8.3","0.0","0.0","0.0","0.0","13.9","56.9","21.2","3.4","0.0","0.0","0.0","0.0","1.0"
"3","E14000532","Altrincham and Sale West","52.9","33.7","10.0","0.0","2.2","0.0","0.0","1.1","59.2","41.4","14.8","0.0","3.9","0.0","0.0","3.3","47.5","26.7","6.2","0.0","1.2","0.0","0.0","0.3"
"4","E14000533","Amber Valley","55.3","34.5","4.7","0.0","1.8","0.0","0.0","3.7","61.5","42.1","8.1","0.0","3.5","0.0","0.0","9.9","48.6","28.2","2.4","0.0","0.7","0.0","0.0","0.8"
"5","E14000534","Arundel and South Downs","60.9","17.
@jblumenau
jblumenau / party_constituency_vote_shares.csv
Created June 9, 2017 02:40
Constituency-level vote share predictions from YouGov MRP GE2017 model
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
"","code","constituency","Con","Lab","LD","UKIP","Green","SNP","PC","Other","Con_lo","Lab_lo","LD_lo","UKIP_lo","Green_lo","SNP_lo","PC_lo","Other_lo","Con_hi","Lab_hi","LD_hi","UKIP_hi","Green_hi","SNP_hi","PC_hi","Other_hi"
"1","E14000530","Aldershot","51.8","29.1","11.0","5.5","2.6","0.0","0.0","0.0","44.4","22.2","6.7","3.0","1.3","0.0","0.0","0.0","58.4","36.4","16.6","8.5","4.8","0.0","0.0","0.0"
"2","E14000531","Aldridge-Brownhills","62.3","29.3","4.8","0.0","0.0","0.0","0.0","3.5","53.9","21.4","2.4","0.0","0.0","0.0","0.0","0.6","69.3","36.5","8.4","0.0","0.0","0.0","0.0","10.8"
"3","E14000532","Altrincham and Sale West","48.6","35.2","11.1","0.0","1.9","0.0","0.0","3.2","41.3","28.5","6.7","0.0","0.8","0.0","0.0","0.6","56.0","42.0","17.0","0.0","3.8","0.0","0.0","8.3"
"4","E14000533","Amber Valley","51.3","40.7","3.2","0.0","2.2","0.0","0.0","2.7","43.9","33.7","1.5","0.0","0.8","0.0","0.0","0.3","58.0","47.4","5.7","0.0","4.7","0.0","0.0","8.8"
"5","E14000534","Arundel and South Downs","58.7","21.
@jblumenau
jblumenau / members_api.R
Created January 27, 2017 22:55
testing the member query api
library(xml2)
members <- read_xml("http://data.parliament.uk/membersdataplatform/services/mnis/members/query/membership=all|house=Commons")
start_dates <- xml_text(xml_find_all(xml_find_all(members, "Member"),"HouseStartDate"))
start_dates <- as.Date(start_dates)
table(start_dates > as.Date("1945-01-01"))
<?xml version="1.0" encoding="iso-8859-1"?>
<twfy><info><s>gid:debate/2008-05-14b.1370.1</s><results_per_page>20</results_per_page><page>1</page><first_result>1</first_result><total_results>1</total_results><spelling_correction></spelling_correction></info><searchdescription>gid:debate/2008-05-14b.1370.1</searchdescription><rows><match><gid>2008-05-14b.1370.1</gid><hdate>2008-05-14</hdate><htime>11:30:00</htime><section_id>14015375</section_id><subsection_id>14015395</subsection_id><htype>12</htype><major>1</major><minor>0</minor><person_id>10651</person_id><hpos>31</hpos><video_status>5</video_status><epobject_id>14015405</epobject_id><body>&lt;p pid=&quot;b.1370.1/1&quot;&gt;The hon. Gentleman is right to draw the attention of the House to the 18th IMC report, which deals with matters relating to organised crime, too. I am sure that he will have noted that significant progress has been made on a number of fronts. However, it is perfectly clear that in one specific area&amp;#8212;that is, in relation to &amp
@jblumenau
jblumenau / ReadMe.txt
Last active July 13, 2016 14:30
Party leader satisfaction from IPSOS Mori
All data taken from https://t.co/rSOl6mIDgf
Please attribute any usage to Ipsos MORI
@jblumenau
jblumenau / scraper.R
Created May 29, 2016 02:24
Script to demonstrate scraping potential of R (created as a teaching example)
#############################################
### A very messy example of scraping in R ###
#############################################
rm(list=ls()) # Remove everything from your current workspace
######################
### Load libraries ###
######################