#!/usr/bin/env python # coding: utf-8 # # Quick Play With EU Ref Data # In[37]: #data from http://www.electoralcommission.org.uk/find-information-by-subject/elections-and-referendums/upcoming-elections-and-referendums/eu-referendum/electorate-and-count-information # In[38]: get_ipython().system('ls EU*') # Load the data in: # In[39]: import pandas as pd #df=pd.read_csv('EU-referendum-result-data.csv') url='http://www.electoralcommission.org.uk/__data/assets/file/0014/212135/EU-referendum-result-data.csv' df=pd.read_csv(url) df[:3] # Check the columns: # In[40]: df.columns # How close were the votes? Count number of areas where difference between remanin and leave was less than or equal to `2 * halfwidth` (i.e. both votes in band `50 +/- halfwidth`. # In[51]: halfwidth=1 df[(abs(df['Pct_Remain']-50)