import pandas as pd
from matplotlib import pyplot as plt
from IPython.display import display
%matplotlib inline
plt.rcParams['figure.figsize'] = (20.0, 10.0)
rhi_csv = 'rhi-nondomestic-beneficiaries-ltd-companies-organisations.csv'
#rhi_csv = 'tabula-RHI-beneficiaries-non-domestic-individuals-companies.csv'
df = pd.read_csv(rhi_csv)
display(df.head())
display(df.dtypes)
Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99 | £27,600.66 | |
---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99.0 | £30,507.19 |
1 | Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99.0 | £34,416.23 |
2 | Acheson & Glover Precast Ltd | 13/07/2015 | BT75 | Solid Biomass Boiler | 99.0 | £50,543.44 |
3 | Acheson & Glover Precast Ltd | 13/07/2015 | BT75 | Solid Biomass Boiler | 99.0 | £52,297.88 |
4 | Acheson & Glover Precast Ltd | 13/07/2015 | BT75 | Solid Biomass Boiler | 99.0 | £53,369.70 |
Acheson & Glover Precast Ltd object 06/11/2015 object BT75 object Solid Biomass Boiler object 99 float64 £27,600.66 object dtype: object
df = pd.read_csv(rhi_csv,
names=['Company','Date','Postcode',
'Type','Capacity (kWtH)', 'Cash']
)
display(df.head())
display(df.dtypes)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99.0 | £27,600.66 |
1 | Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99.0 | £30,507.19 |
2 | Acheson & Glover Precast Ltd | 06/11/2015 | BT75 | Solid Biomass Boiler | 99.0 | £34,416.23 |
3 | Acheson & Glover Precast Ltd | 13/07/2015 | BT75 | Solid Biomass Boiler | 99.0 | £50,543.44 |
4 | Acheson & Glover Precast Ltd | 13/07/2015 | BT75 | Solid Biomass Boiler | 99.0 | £52,297.88 |
Company object Date object Postcode object Type object Capacity (kWtH) float64 Cash object dtype: object
df = pd.read_csv(rhi_csv,
names=['Company','Date','Postcode',
'Type','Capacity (kWtH)', 'Cash'] )
df['Date'] = pd.to_datetime(df['Date'])
display(df.head())
display(df.dtypes)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 2015-06-11 | BT75 | Solid Biomass Boiler | 99.0 | £27,600.66 |
1 | Acheson & Glover Precast Ltd | 2015-06-11 | BT75 | Solid Biomass Boiler | 99.0 | £30,507.19 |
2 | Acheson & Glover Precast Ltd | 2015-06-11 | BT75 | Solid Biomass Boiler | 99.0 | £34,416.23 |
3 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | £50,543.44 |
4 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | £52,297.88 |
Company object Date datetime64[ns] Postcode object Type object Capacity (kWtH) float64 Cash object dtype: object
df = pd.read_csv(rhi_csv,
names=['Company','Date','Postcode',
'Type','Capacity (kWtH)', 'Cash'] )
df['Date'] = pd.to_datetime(df['Date'], format='%d/%m/%Y')
display(df.head())
display(df.dtypes)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | £27,600.66 |
1 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | £30,507.19 |
2 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | £34,416.23 |
3 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | £50,543.44 |
4 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | £52,297.88 |
Company object Date datetime64[ns] Postcode object Type object Capacity (kWtH) float64 Cash object dtype: object
df = pd.read_csv(rhi_csv,
names=['Company','Date','Postcode',
'Type','Capacity (kWtH)', 'Cash']
)
df['Date'] = pd.to_datetime(df['Date'], format='%d/%m/%Y')
df['Cash'] = df['Cash'].replace('[£,]','', regex=True).astype(float)
display(df.head())
display(df.dtypes)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 27600.66 |
1 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 30507.19 |
2 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 34416.23 |
3 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 50543.44 |
4 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 52297.88 |
Company object Date datetime64[ns] Postcode object Type object Capacity (kWtH) float64 Cash float64 dtype: object
df.Cash.describe()
count 874.000000 mean 31603.964554 std 21591.062908 min 73.220000 25% 14771.700000 50% 28999.740000 75% 44733.297500 max 252844.050000 Name: Cash, dtype: float64
f,ax = plt.subplots()
df.Cash.hist(ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7f96d92e6f60>
df.Postcode.unique()
array(['BT75', 'BT80', 'BT62', 'BT46', 'BT70', 'BT31', 'BT81', 'BT79', 'BT77', 'BT44', 'BT94', 'BT60', 'BT78', 'BT92', 'BT28', 'BT61', nan, 'BT54', 'BT39', 'BT34', 'BT19', 'BT20', 'BT53', 'BT67', 'BT63', 'BT23', 'BT42', 'BT09', 'BT08', 'BT29', 'BT74', 'BT25', 'BT45', 'BT04', 'BT27', 'BT33', 'BT68', 'BT71', 'BT47', 'BT35', 'BT12', 'BT43', 'BT41', 'BT32', 'BT22', 'BT21', 'BT51', 'BT48', 'BT49', 'BT24', 'BT17', 'BT06', 'BT93', 'BT82', 'BT66', 'BT56', 'BT26', 'BT40', 'BT76', 'BT05', 'BA14', 'BT36', 'Bt78', 'BT03', 'BT64', 'BT57'], dtype=object)
df.Postcode.isnull()
0 False 1 False 2 False 3 False 4 False 5 False 6 False 7 False 8 False 9 False 10 False 11 False 12 False 13 False 14 False 15 False 16 False 17 False 18 False 19 False 20 False 21 False 22 False 23 False 24 False 25 False 26 False 27 False 28 False 29 False ... 849 False 850 False 851 False 852 False 853 False 854 False 855 False 856 False 857 False 858 False 859 False 860 False 861 False 862 False 863 False 864 False 865 False 866 False 867 False 868 False 869 False 870 False 871 False 872 False 873 False 874 False 875 False 876 False 877 False 878 False Name: Postcode, dtype: bool
df.dropna(how='all', inplace=True)
df.Postcode.sort_values().unique()
array(['BA14', 'BT03', 'BT04', 'BT05', 'BT06', 'BT08', 'BT09', 'BT12', 'BT17', 'BT19', 'BT20', 'BT21', 'BT22', 'BT23', 'BT24', 'BT25', 'BT26', 'BT27', 'BT28', 'BT29', 'BT31', 'BT32', 'BT33', 'BT34', 'BT35', 'BT36', 'BT39', 'BT40', 'BT41', 'BT42', 'BT43', 'BT44', 'BT45', 'BT46', 'BT47', 'BT48', 'BT49', 'BT51', 'BT53', 'BT54', 'BT56', 'BT57', 'BT60', 'BT61', 'BT62', 'BT63', 'BT64', 'BT66', 'BT67', 'BT68', 'BT70', 'BT71', 'BT74', 'BT75', 'BT76', 'BT77', 'BT78', 'BT79', 'BT80', 'BT81', 'BT82', 'BT92', 'BT93', 'BT94', 'Bt78'], dtype=object)
# df['Postcode'] = df['Postcode'].apply(str.upper)
df['Postcode'] = df['Postcode'].str.upper()
df[df.Postcode=='BA14'] # df.query("Postcode == 'BA14'")
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
616 | National Trust (Crom Estate) | 2014-01-27 | BA14 | Solid Biomass Boiler | 99.0 | 31564.68 |
617 | National Trust (Florence Court) | 2015-05-28 | BA14 | Solid Biomass Boiler | 36.0 | 3148.25 |
618 | National Trust (Giant's Causeway Visitors' Cen... | 2015-02-23 | BA14 | Ground Source Heat Pump (GSHP) | 71.0 | 8634.47 |
619 | National Trust (Innisfee) | 2013-11-30 | BA14 | Solid Biomass Boiler | 99.0 | 22766.50 |
620 | National Trust (Springhill House) | 2013-11-30 | BA14 | Solid Biomass Boiler | 80.0 | 22717.76 |
621 | National Trust (Springhill) | 2013-11-30 | BA14 | Solid Biomass Boiler | 30.0 | 4133.90 |
622 | National Trust (The Argory) | 2015-11-01 | BA14 | Solid Biomass Boiler | 95.0 | 6005.90 |
623 | National Trust (The Argory) | 2015-11-01 | BA14 | Solid Biomass Boiler | 35.0 | 3448.73 |
df.Cash.sum()
27621865.020000003
df.groupby('Postcode')['Cash'].sum().sort_values().head(20)
Postcode BT21 22866.87 BT64 24221.85 BT56 28305.90 BT63 28336.19 BT17 32642.83 BT06 34574.91 BT26 39251.72 BT36 42028.65 BT57 46342.01 BT40 48995.53 BT81 51449.64 BT22 52931.06 BT03 57728.22 BT54 62948.10 BT04 65704.29 BT43 68431.81 BT20 69649.89 BT24 77451.18 BT76 85234.82 BT19 90062.63 Name: Cash, dtype: float64
f,ax = plt.subplots()
_=df.groupby('Postcode')['Cash'].sum().hist(ax=ax)
f,ax = plt.subplots()
_=df.groupby('Postcode')['Cash'].sum().sort_values(ascending=False).plot.pie(ax=ax)
def make_autopct(total):
def my_autopct(pct):
val = int(round(pct*total/100.0))
return '{p:.1f}% (£{v:,.1f}m)'.format(p=pct,v=val/1000000)
return my_autopct
f,ax = plt.subplots()
_=df.groupby('Postcode')['Cash'].sum().sort_values(ascending=False)\
.plot.pie(ax=ax, autopct=make_autopct(df.Cash.sum()))
ea_url = "http://www.eoni.org.uk/Elections/Electoral-areas"
import urllib
_url = urllib.parse.urlparse(ea_url)
_base_url = _url.scheme + '://' + _url.netloc
import requests
from bs4 import BeautifulSoup as bs
r = bs(requests.get(_url.geturl()).text, 'lxml')
for link in r.find_all('a'):
print(link.contents)
['Sitemap'] ['About EONI'] ['Contact Us'] [<img alt="The Electoral Office for Northern Ireland home" id="p_lt_ctl01_Logo_btnElem_image" src="/getmedia/83efe217-5085-4f5e-b2bd-9088bb8323d0/logo?width=359&height=86&ext=.jpg" title="The Electoral Office for Northern Ireland home"/>, <span id="p_lt_ctl01_Logo_btnElem_lblText"></span>] [<img alt="follow us on Twitter" id="p_lt_ctl03_TwitterFeed_btnElem_image" src="/getmedia/6299767c-bc92-482b-af27-8d6bfaf30c2c/icon-twitter?width=30&height=30&ext=.png" title="follow us on Twitter"/>, <span id="p_lt_ctl03_TwitterFeed_btnElem_lblText"></span>] ['Home'] ['News'] ['Register To Vote'] ['Voting'] ['Elections'] ['Electoral Identity Card'] ['FAQs'] ['Elections'] ['Wards by Constituency (PDF)'] ['Wards by District (PDF)'] ['Wards by District Electoral Area (PDF)'] ['Belfast East Street Index 2017 (XLS)'] ['Belfast North Street Index 2017 (XLS)'] ['Belfast South Street Index 2017 (XLS)'] ['Belfast West Street Index 2017 (XLS)'] ['East Antrim Street Index 2017 (XLS)'] ['East Londonderry Street Index 2017 (XLS)'] ['Fermanagh and South Tyrone Street Index 2017 (XLS)'] ['Foyle Street Index 2017 (XLS)'] ['Lagan Valley Street Index 2017 (XLS)'] ['Mid Ulster Street Index 2017 (XLS)'] ['Newry and Armagh Street Index 2017 (XLS)'] ['North Antrim Street Index 2017 (XLS)'] ['North Down Street Index 2017 (XLS)'] ['South Antrim Street Index 2017 (XLS)'] ['South Down Street Index 2017 (XLS)'] ['Strangford Street Index 2017 (XLS)'] ['Upper Bann Street Index 2017 (XLS)'] ['West Tyrone Street Index 2017 (XLS)'] ['Types of election'] ['Election results and statistics'] ['Election results and statistics 2003 onwards'] ['Elections 2017'] ['NI Assembly Election 2017 - Notices of Appointment of Election Agents'] ['NI Assembly Election 2017 - Result Declarations'] ['NI Assembly Election 2017 - Result Sheet'] ['NI Assembly Election 2017 - Statements of Persons Nominated'] ['Elections 2016'] ['NI Assembly Election 2016 - Result Declarations'] ['NI Assembly Election 2016 - Result Sheets'] ['NI Assembly Election 2016 - Statements of Persons Nominated'] ['NI Assembly Election 2016 - Notices of Appointment of Election Agents'] ['Elections 2015'] ['UK Parliamentary Election - Statements of Persons Nominated'] ['UK Parliamentary Election - Results'] ['UK Parliamentary Election Result - Belfast East'] ['UK Parliamentary Election Result - Belfast North'] ['UK Parliamentary Election Result - Belfast South'] ['UK Parliamentary Election Result - Belfast West'] ['UK Parliamentary Election Result - East Antrim'] ['UK Parliamentary Election Result - East Londonderry'] ['UK Parliamentary Election Result - Fermanagh & South Tyrone'] ['UK Parliamentary Election Result - Foyle'] ['UK Parliamentary Election Result - Lagan Valley'] ['UK Parliamentary Election Result - Mid Ulster'] ['UK Parliamentary Election Result - Newry & Armagh'] ['UK Parliamentary Election Result - North Antrim'] ['UK Parliamentary Election Result - North Down'] ['UK Parliamentary Election Result - South Antrim'] ['UK Parliamentary Election Result - South Down'] ['UK Parliamentary Election Result - Strangford'] ['UK Parliamentary Election Result - Upper Bann'] ['UK Parliamentary Election Result - West Tyrone'] ['Elections 2014'] ['Local Council Elections 2014 - Results by Stage'] ['Elections 2013'] ['Elections 2011'] ['NI Assembly election candidates nominated'] ['NI Assembly election candidates elected'] ['NI Assembly election results by stage'] ['Local Council Election Results by Stage'] ['Belfast West by-election results and statistics'] ['Elections 2010'] ['Election results'] ['Elections 2009'] ['Elections 2007'] ['Results'] ['NI Assembly Election 2007 - Full Results'] ['Statistics'] ['Elections 2005'] ['Elections 2004'] ['Elections 2003'] ['Election results 1973-2001'] ['By-election results'] ['By-elections and substitutions'] ['Electoral areas'] ['Information for local councils'] ['Polling stations'] ['Information for candidates and agents'] ['Count Information Packs'] ['Notice of Appointment of Election Agents'] ['Notice of Issue and Opening of Postal Votes'] ['Statement of Persons Nominated and Notice of Poll'] ['Media Centre'] ['Media Accreditation Form'] ['Accessibility'] ['Contact Us'] ['Copyright'] ['FAQs'] [<img alt="Employers for Disability" id="p_lt_ctl10_FooterLogoRight_btnElem_image" src="/getmedia/2a537dc1-c235-432f-8f3c-880a033334ea/efdni_1?width=129&height=77&ext=.png" title="Employers for Disability"/>, <span id="p_lt_ctl10_FooterLogoRight_btnElem_lblText"></span>] ['i3Digital'] ['Kentico']
constituency_urls = {}
for link in r.find_all('a'):
if str(link.contents[0]).endswith('(XLS)'):
constituency = ' '.join(link.contents[0].split()[:-4])
constituency_urls[constituency] = _base_url+link.get('href')
print(constituency,constituency_urls[constituency])
Belfast East http://www.eoni.org.uk/getmedia/ed993710-4b80-46f5-ae6e-ecaf57ed78e8/Belfast-East-Street-Index-18-11-16_1 Belfast North http://www.eoni.org.uk/getmedia/57e481c9-0299-4cee-b3d5-339f1d902405/Belfast-North-Street-Index-18-11-16 Belfast South http://www.eoni.org.uk/getmedia/4616c6ce-52ba-4695-b09d-4eef48580068/Belfast-South-Street-Index-18-11-16 Belfast West http://www.eoni.org.uk/getmedia/aac9bb32-105d-45b9-9f89-46f237e2f9f7/Belfast-West-Street-Index-18-11-16 East Antrim http://www.eoni.org.uk/getmedia/b8193e4d-d21b-4c93-96cf-54029513f9d2/East-Antrim-Street-Index-18-11-16 East Londonderry http://www.eoni.org.uk/getmedia/9f97bc2a-e95a-4a6f-b46a-7b4c1f7aea99/East-Londonderry-Street-Index-18-11-16 Fermanagh and South Tyrone http://www.eoni.org.uk/getmedia/f03947bc-7eca-4c49-a244-1765e4492407/Fermanagh-and-South-Tyrone-Street-Index-18-11-16 Foyle http://www.eoni.org.uk/getmedia/22100a16-1ed1-4440-a24d-7d0508261d2b/Foyle-Street-Index-18-11-16 Lagan Valley http://www.eoni.org.uk/getmedia/0ae3e92b-8db7-4667-bf49-19a3d8d30fb6/Lagan-Valley-Street-Index-18-11-16 Mid Ulster http://www.eoni.org.uk/getmedia/8071d70b-4d05-44e8-9ab1-c17ebeb2dbb5/Mid-Ulster-Street-Index-18-11-16 Newry and Armagh http://www.eoni.org.uk/getmedia/77fffc7b-8801-4fc2-bda2-42cc1979e711/Newry-and-Armagh-Street-Index-18-11-16 North Antrim http://www.eoni.org.uk/getmedia/966baf78-2dd4-48f9-a1b3-6c9b6abf2f06/North-Antrim-Street-Index-18-11-16 North Down http://www.eoni.org.uk/getmedia/37bd5e8a-273e-4ae4-8cdc-69c380e5139f/North-Down-Street-Index-18-11-16 South Antrim http://www.eoni.org.uk/getmedia/b2e31e8b-f978-4f94-b023-91bc808d3a81/South-Antrim-Street-Index-18-11-16 South Down http://www.eoni.org.uk/getmedia/9fd78e7c-8293-449d-8fa5-8114da47fd7b/South-Down-Street-Index-18-11-16 Strangford http://www.eoni.org.uk/getmedia/266bb298-9cdb-4898-a193-4dc75110d078/Strangford-Street-Index-18-11-16 Upper Bann http://www.eoni.org.uk/getmedia/99a4f2d6-4e3f-451e-98d4-20dcda703c0a/Upper-Bann-Street-Index-18-11-16 West Tyrone http://www.eoni.org.uk/getmedia/c1a00455-b9bb-4b20-b512-688a71eab057/West-Tyrone-Street-Index-18-11-16
pd.read_excel(constituency_urls['North Antrim']).head()
NORTH ANTRIM CONSTITUENCY | Unnamed: 1 | Unnamed: 2 | Unnamed: 3 | |
---|---|---|---|---|
0 | NaN | NaN | NaN | NaN |
1 | Ward | Street | Postal Address | Post Code |
2 | 0401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA |
3 | 0401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD |
4 | 0401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW |
pd.read_excel(constituency_urls['North Antrim'], skiprows=3).head()
Ward | Street | Postal Address | Post Code | |
---|---|---|---|---|
0 | 401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA |
1 | 401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD |
2 | 401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW |
3 | 401 | BALLYMACFIN ROAD | BALLYMACFIN, MOSSIDE | BT53 8EJ |
4 | 401 | BALLYNARRY ROAD | DEEPSTOWN, BALLYMONEY | BT53 8AE |
_cons_df = pd.read_excel(constituency_urls['North Antrim'], skiprows=3)
_cons_df['Base Post Code'] = _cons_df['Post Code'].apply(lambda s: s.split()[0])
_cons_df.head()
Ward | Street | Postal Address | Post Code | Base Post Code | |
---|---|---|---|---|---|
0 | 401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA | BT53 |
1 | 401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD | BT53 |
2 | 401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW | BT53 |
3 | 401 | BALLYMACFIN ROAD | BALLYMACFIN, MOSSIDE | BT53 8EJ | BT53 |
4 | 401 | BALLYNARRY ROAD | DEEPSTOWN, BALLYMONEY | BT53 8AE | BT53 |
_cons_df = pd.read_excel(constituency_urls['North Antrim'], skiprows=3)
_cons_df['Base Post Code'] = _cons_df['Post Code'].apply(lambda s: s.split()[0])
_cons_df.head()
Ward | Street | Postal Address | Post Code | Base Post Code | |
---|---|---|---|---|---|
0 | 401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA | BT53 |
1 | 401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD | BT53 |
2 | 401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW | BT53 |
3 | 401 | BALLYMACFIN ROAD | BALLYMACFIN, MOSSIDE | BT53 8EJ | BT53 |
4 | 401 | BALLYNARRY ROAD | DEEPSTOWN, BALLYMONEY | BT53 8AE | BT53 |
constituency_frames = {}
for _constituency, _url in constituency_urls.items():
_cons_df = pd.read_excel(_url, skiprows=3)
_cons_df['Base Post Code'] = _cons_df['Post Code'].apply(lambda s: s.split()[0])
constituency_frames[_constituency] = _cons_df
constituency_frames['North Antrim'].head()
Ward | Street | Postal Address | Post Code | Base Post Code | |
---|---|---|---|---|---|
0 | 401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA | BT53 |
1 | 401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD | BT53 |
2 | 401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW | BT53 |
3 | 401 | BALLYMACFIN ROAD | BALLYMACFIN, MOSSIDE | BT53 8EJ | BT53 |
4 | 401 | BALLYNARRY ROAD | DEEPSTOWN, BALLYMONEY | BT53 8AE | BT53 |
But there's a better way to do this; add the constituency information to each row using a single assign
Then simply concatenate all the frames together into one big one
_cons_df = pd.read_excel(constituency_urls['North Antrim'], skiprows=3)
_cons_df['Base Post Code'] = _cons_df['Post Code'].apply(lambda s: s.split()[0])
_cons_df['Constituency'] = 'North Antrim'
_cons_df.head()
Ward | Street | Postal Address | Post Code | Base Post Code | Constituency | |
---|---|---|---|---|---|---|
0 | 401 | BALLINDREEN ROAD | BALLYBOGY, BALLYMONEY | BT53 6PA | BT53 | North Antrim |
1 | 401 | BALLYBOGY ROAD | TULLAGHGORE, BALNAMORE | BT53 6NX, BT53 6NY, BT53 6PD, BT53 6PG, BT53 6QD | BT53 | North Antrim |
2 | 401 | BALLYCLOGH ROAD | SHELLFIELD, BALLYMONEY | BT53 6NW | BT53 | North Antrim |
3 | 401 | BALLYMACFIN ROAD | BALLYMACFIN, MOSSIDE | BT53 8EJ | BT53 | North Antrim |
4 | 401 | BALLYNARRY ROAD | DEEPSTOWN, BALLYMONEY | BT53 8AE | BT53 | North Antrim |
constituency_frames = {}
for _constituency, _url in constituency_urls.items():
_cons_df = pd.read_excel(_url, skiprows=3)
_cons_df['Base Post Code'] = _cons_df['Post Code'].apply(lambda s: s.split()[0])
_cons_df['Constituency'] = _constituency
constituency_frames[_constituency] = _cons_df
constituency_frame = pd.concat(constituency_frames.values())
constituency_frame.head()
Ward | Street | Postal Address | Post Code | Base Post Code | Constituency | |
---|---|---|---|---|---|---|
0 | 2510 | BREDA AVENUE | BELFAST | BT8 6JS | BT8 | Belfast South |
1 | 2510 | BREDA COURT | BELFAST | BT8 6JB | BT8 | Belfast South |
2 | 2510 | BREDA CRESCENT | BELFAST | BT8 6JT | BT8 | Belfast South |
3 | 2510 | BREDA DRIVE | BELFAST | BT8 6JU | BT8 | Belfast South |
4 | 2510 | BREDA MEWS | BELFAST | BT8 6JD | BT8 | Belfast South |
We've only got time to look at the postcode-constituency angle, so we'll focus on those columns
constituency_frame[['Base Post Code','Constituency']].head()
Base Post Code | Constituency | |
---|---|---|
0 | BT8 | Belfast South |
1 | BT8 | Belfast South |
2 | BT8 | Belfast South |
3 | BT8 | Belfast South |
4 | BT8 | Belfast South |
However, because postcodes suck, the mapping from Post code to Constituency, especially with only the first part as reported in the RHI stats, is not one-to-one
constituency_frame[constituency_frame['Base Post Code'] == 'BT41']\
.Constituency.unique()
array(['Mid Ulster', 'East Londonderry', 'North Antrim', 'East Antrim', 'South Antrim'], dtype=object)
constituency_frame[['Base Post Code','Constituency']]\
.groupby('Base Post Code')['Constituency'].describe()\
.unstack().sort_values('unique').tail()
count | unique | top | freq | |
---|---|---|---|---|
Base Post Code | ||||
BT17 | 448 | 4 | Belfast West | 301 |
BT71 | 825 | 4 | Fermanagh and South Tyrone | 392 |
BT39 | 490 | 4 | South Antrim | 455 |
BT32 | 532 | 4 | Upper Bann | 372 |
BT41 | 704 | 5 | South Antrim | 650 |
postcode_cons_map = constituency_frame[['Base Post Code','Constituency']]\
.groupby('Base Post Code')['Constituency'].max()\
.to_frame().reset_index()
postcode_cons_map
Base Post Code | Constituency | |
---|---|---|
0 | BFPO | South Antrim |
1 | BT | Foyle |
2 | BT1 | Belfast West |
3 | BT10 | Belfast West |
4 | BT11 | Belfast West |
5 | BT12 | Belfast West |
6 | BT13 | Belfast West |
7 | BT14 | South Antrim |
8 | BT15 | Belfast North |
9 | BT16 | Strangford |
10 | BT17 | South Antrim |
11 | BT18 | North Down |
12 | BT19 | Strangford |
13 | BT2 | Belfast South |
14 | BT20 | North Down |
15 | BT21 | Strangford |
16 | BT22 | Strangford |
17 | BT23 | Strangford |
18 | BT24 | Strangford |
19 | BT25 | Upper Bann |
20 | BT26 | Lagan Valley |
21 | BT27 | Lagan Valley |
22 | BT28 | Upper Bann |
23 | BT29 | South Antrim |
24 | BT3 | Belfast East |
25 | BT30 | Strangford |
26 | BT31 | South Down |
27 | BT32 | Upper Bann |
28 | BT32, | Upper Bann |
29 | BT33 | South Down |
... | ... | ... |
54 | BT56 | East Londonderry |
55 | BT57 | North Antrim |
56 | BT6 | Strangford |
57 | BT60 | Newry and Armagh |
58 | BT61 | Newry and Armagh |
59 | BT62 | Upper Bann |
60 | BT63 | Upper Bann |
61 | BT64 | Upper Bann |
62 | BT65 | Upper Bann |
63 | BT66 | Upper Bann |
64 | BT67 | Upper Bann |
65 | BT68 | Fermanagh and South Tyrone |
66 | BT69 | Fermanagh and South Tyrone |
67 | BT7 | Fermanagh and South Tyrone |
68 | BT70 | West Tyrone |
69 | BT71 | Upper Bann |
70 | BT74 | Fermanagh and South Tyrone |
71 | BT75 | Fermanagh and South Tyrone |
72 | BT76 | West Tyrone |
73 | BT77 | Fermanagh and South Tyrone |
74 | BT78 | West Tyrone |
75 | BT79 | West Tyrone |
76 | BT8 | Strangford |
77 | BT80 | Mid Ulster |
78 | BT81 | West Tyrone |
79 | BT82 | West Tyrone |
80 | BT9 | Belfast South |
81 | BT92 | Fermanagh and South Tyrone |
82 | BT93 | West Tyrone |
83 | BT94 | Fermanagh and South Tyrone |
84 rows × 2 columns
SQL-style joins (yes, it does inner, outer, left etc)
postcode_cons_map = postcode_cons_map.rename(columns={'Base Post Code':'Postcode'})
con_df=pd.merge(df,postcode_cons_map, on='Postcode', how='left')
display(df.shape)
display(con_df.shape)
con_df
(874, 6)
(874, 7)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | Constituency | |
---|---|---|---|---|---|---|---|
0 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 27600.66 | Fermanagh and South Tyrone |
1 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 30507.19 | Fermanagh and South Tyrone |
2 | Acheson & Glover Precast Ltd | 2015-11-06 | BT75 | Solid Biomass Boiler | 99.0 | 34416.23 | Fermanagh and South Tyrone |
3 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 50543.44 | Fermanagh and South Tyrone |
4 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 52297.88 | Fermanagh and South Tyrone |
5 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 53369.70 | Fermanagh and South Tyrone |
6 | Acheson & Glover Precast Ltd | 2015-07-13 | BT75 | Solid Biomass Boiler | 99.0 | 53475.84 | Fermanagh and South Tyrone |
7 | ACL Developments Ltd | 2015-11-06 | BT80 | Solid Biomass Boiler | 43.0 | 7209.13 | Mid Ulster |
8 | Agricultural and Industrial Services 2012 Limited | 2015-11-09 | BT62 | Solid Biomass Boiler | 99.0 | 21627.16 | Upper Bann |
9 | Alexander Scott & Son Ltd | 2015-07-31 | BT46 | Solid Biomass Boiler | 99.0 | 9504.53 | Mid Ulster |
10 | All Spares ATVs Ltd | 2014-10-15 | BT70 | Solid Biomass Boiler | 99.0 | 46174.37 | West Tyrone |
11 | All Spares ATVs Ltd | 2015-09-30 | BT70 | Solid Biomass Boiler | 99.0 | 28484.74 | West Tyrone |
12 | Alternative Heat Ltd | 2013-01-23 | BT31 | Solid Biomass Boiler | 75.0 | 6995.34 | South Down |
13 | Alternative Heat Ltd | 2016-02-10 | BT31 | Solid Biomass Boiler | 199.0 | 7099.18 | South Down |
14 | Alternative Heat Ltd | 2015-06-10 | BT31 | Solid Biomass Boiler | 99.0 | 14937.99 | South Down |
15 | Altmor Limited T/A Valleyview Enterprises - Pi... | 2015-10-14 | BT81 | Solid Biomass Boiler | 95.0 | 30440.15 | West Tyrone |
16 | Altmore Farm Ltd | 2015-10-20 | BT70 | Solid Biomass Boiler | 99.0 | 45866.87 | West Tyrone |
17 | Altmore Farm Ltd | 2015-10-20 | BT70 | Solid Biomass Boiler | 99.0 | 44786.34 | West Tyrone |
18 | Altmore Farm Ltd | 2015-10-20 | BT70 | Solid Biomass Boiler | 99.0 | 43032.60 | West Tyrone |
19 | An Charraig Mhor GFC | 2015-10-27 | BT79 | Solid Biomass Boiler | 99.0 | 14880.24 | West Tyrone |
20 | Annagarvey Holdings Ltd | 2015-06-09 | BT77 | Solid Biomass Boiler | 65.0 | 8333.41 | Fermanagh and South Tyrone |
21 | Antrim Estates Company | 2016-02-10 | BT44 | Solid Biomass Boiler | 195.0 | 11958.15 | North Antrim |
22 | ARC Healthy Living Centre Ltd | 2015-07-02 | BT94 | Solid Biomass Boiler | 99.0 | 15421.47 | Fermanagh and South Tyrone |
23 | Armagh Business Park Ltd | 2015-10-17 | BT60 | Solid Biomass Boiler | 99.0 | 30909.58 | Newry and Armagh |
24 | Armagh Cider Company Ltd | 2015-11-16 | BT62 | Solid Biomass Boiler | 99.0 | 9826.61 | Upper Bann |
25 | Armagh Cider Company Ltd | 2015-11-16 | BT62 | Solid Biomass Boiler | 99.0 | 17365.98 | Upper Bann |
26 | Augher Castle Limited | 2015-10-12 | BT77 | Solid Biomass Boiler | 99.0 | 15097.56 | Fermanagh and South Tyrone |
27 | AWF Poultry Ltd | 2015-11-08 | BT78 | Solid Biomass Boiler | 99.0 | 16194.13 | West Tyrone |
28 | AWF Poultry Ltd | 2015-11-08 | BT78 | Solid Biomass Boiler | 99.0 | 17084.47 | West Tyrone |
29 | B P Mc Keefry Ltd | 2014-04-05 | BT46 | Solid Biomass Boiler | 99.0 | 34067.13 | Mid Ulster |
... | ... | ... | ... | ... | ... | ... | ... |
844 | Vision Heat Solutions Limited | 2015-03-11 | BT42 | Solid Biomass Boiler | 99.0 | 32756.94 | South Antrim |
845 | Vision Heat Solutions Limited | 2015-11-11 | BT42 | Solid Biomass Boiler | 98.0 | 33670.82 | South Antrim |
846 | Vision Heat Solutions Limited | 2015-11-11 | BT42 | Solid Biomass Boiler | 98.0 | 35857.10 | South Antrim |
847 | Vision Heat Solutions Limited | 2014-07-11 | BT42 | Solid Biomass Boiler | 97.0 | 48959.35 | South Antrim |
848 | W & A Nixon & Sons Ltd | 2016-02-26 | BT82 | Solid Biomass Boiler | 199.0 | 5682.95 | West Tyrone |
849 | W J Hanna Machinery LTD | 2015-10-23 | BT45 | Solid Biomass Boiler | 99.0 | 24504.12 | Mid Ulster |
850 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 15385.54 | Upper Bann |
851 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 13290.92 | Upper Bann |
852 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 24936.44 | Upper Bann |
853 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 17747.58 | Upper Bann |
854 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 14392.24 | Upper Bann |
855 | Warmflow Engineering Co Ltd | 2015-11-03 | BT28 | Solid Biomass Boiler | 90.0 | 16629.45 | Upper Bann |
856 | Westville Hotel Limited | 2015-01-07 | BT74 | Solid Biomass Boiler | 99.0 | 33136.21 | Fermanagh and South Tyrone |
857 | William Bell Tractors Ltd | 2015-11-05 | BT75 | Solid Biomass Boiler | 99.0 | 10972.40 | Fermanagh and South Tyrone |
858 | Wilson Poultry Ltd | 2016-02-23 | BT92 | Solid Biomass Boiler | 198.0 | 12384.85 | Fermanagh and South Tyrone |
859 | Wilson Property Ltd | 2014-03-21 | BT41 | Solid Biomass Boiler | 97.0 | 24116.56 | South Antrim |
860 | Winters Renewables Ltd | 2015-02-06 | BT78 | Solid Biomass Boiler | 99.0 | 55603.60 | West Tyrone |
861 | Winters Renewables Ltd | 2015-02-06 | BT78 | Solid Biomass Boiler | 99.0 | 48986.02 | West Tyrone |
862 | Winters Renewables Ltd | 2015-09-22 | BT78 | Solid Biomass Boiler | 99.0 | 28321.73 | West Tyrone |
863 | Woodland Kitchens (N.I.) Ltd | 2015-11-03 | BT44 | Solid Biomass Boiler | 95.0 | 11811.21 | North Antrim |
864 | Woodland Kitchens (N.I.) Ltd | 2015-11-03 | BT44 | Solid Biomass Boiler | 95.0 | 16208.70 | North Antrim |
865 | Woodland Kitchens (N.I.) Ltd | 2015-11-03 | BT44 | Solid Biomass Boiler | 95.0 | 22270.75 | North Antrim |
866 | Woodland Kitchens (N.I.) Ltd | 2015-11-03 | BT44 | Solid Biomass Boiler | 95.0 | 24337.67 | North Antrim |
867 | Woodvale Construction Company Ltd | 2015-10-27 | BT79 | Solid Biomass Boiler | 50.0 | 8805.18 | West Tyrone |
868 | Woodvale Construction Company Ltd | 2015-11-09 | BT79 | Solid Biomass Boiler | 99.0 | 17016.91 | West Tyrone |
869 | Woodvale Construction Company Ltd | 2015-11-09 | BT79 | Solid Biomass Boiler | 49.0 | 4138.04 | West Tyrone |
870 | Wrights Poultry Ltd | 2016-02-22 | BT77 | Solid Biomass Boiler | 199.0 | 13727.99 | Fermanagh and South Tyrone |
871 | Wrights Poultry Ltd | 2016-02-22 | BT77 | Solid Biomass Boiler | 199.0 | 17171.61 | Fermanagh and South Tyrone |
872 | Youth With A Mission (NI) Ltd | 2015-10-20 | BT34 | Solid Biomass Boiler | 99.0 | 10892.78 | Upper Bann |
873 | Youth With A Mission (NI) Ltd | 2015-10-20 | BT34 | Solid Biomass Boiler | 99.0 | 11951.91 | Upper Bann |
874 rows × 7 columns
Pass-through plotting arguments to matplotlib
(i.e. autopct
)
f,ax = plt.subplots()
_=con_df.groupby('Constituency')['Cash'].sum().sort_values(ascending=False).plot.pie(ax=ax, autopct='%.2f%%')
f,ax = plt.subplots()
_=con_df.groupby('Constituency')['Cash'].sum().sort_values(ascending=False).plot.pie(ax=ax, autopct=make_autopct(df.Cash.sum()))
f,ax = plt.subplots()
_=con_df.groupby('Constituency')['Cash'].sum().sort_values(ascending=False).plot.pie(ax=ax, autopct=make_autopct(df.Cash.sum()))
con_df.groupby(pd.TimeGrouper(key='Date',freq='M')).size()
Date 2013-01-31 2 2013-02-28 2 2013-03-31 2 2013-04-30 1 2013-05-31 5 2013-06-30 5 2013-07-31 4 2013-08-31 7 2013-09-30 6 2013-10-31 5 2013-11-30 7 2013-12-31 10 2014-01-31 5 2014-02-28 5 2014-03-31 8 2014-04-30 7 2014-05-31 6 2014-06-30 14 2014-07-31 8 2014-08-31 9 2014-09-30 11 2014-10-31 12 2014-11-30 16 2014-12-31 14 2015-01-31 27 2015-02-28 10 2015-03-31 32 2015-04-30 19 2015-05-31 16 2015-06-30 19 2015-07-31 19 2015-08-31 14 2015-09-30 40 2015-10-31 267 2015-11-30 181 2015-12-31 1 2016-01-31 0 2016-02-29 58 Freq: M, dtype: int64
f,ax = plt.subplots()
con_df.groupby(pd.TimeGrouper(key='Date',freq='M'))['Cash'].sum().plot(ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7f96c9fd9eb8>
con_df.groupby([pd.TimeGrouper(key='Date',freq='M'),'Constituency'])['Cash']\
.sum().unstack().head()
Constituency | Belfast West | East Londonderry | Fermanagh and South Tyrone | Foyle | Lagan Valley | Mid Ulster | Newry and Armagh | North Antrim | North Down | South Antrim | South Down | Strangford | Upper Bann | West Tyrone |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Date | ||||||||||||||
2013-01-31 | NaN | NaN | 64016.5 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 6995.34 | NaN | NaN | NaN |
2013-02-28 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 27822.92 | NaN | NaN | NaN | 19873.24 |
2013-03-31 | 37234.47 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 38638.25 |
2013-04-30 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 26159.07 | NaN | NaN | NaN | NaN | NaN | NaN |
2013-05-31 | NaN | NaN | NaN | 51611.56 | NaN | 172751.55 | NaN | NaN | NaN | NaN | NaN | NaN | 84285.55 | 58044.85 |
from matplotlib import dates
import matplotlib.ticker as tick
def _x_month_formatter(x,y):
return '{year}-{month}'.format(year=x.year, month=x.month)
f,ax = plt.subplots()
_con_df_month_con=con_df.groupby([pd.TimeGrouper(key='Date',freq='M'),'Constituency'])['Cash'].sum().unstack()
_con_df_month_con.plot.bar(ax=ax, stacked=True, cmap=plt.get_cmap('Vega20'))
ax.yaxis.set_major_formatter(tick.FuncFormatter(lambda x,y: '£{:,d}k'.format(y)))
ax.xaxis.set_major_formatter(tick.FixedFormatter(_con_df_month_con.index.map(lambda d: '{}-{}'.format(d.year,d.month))))
_=plt.setp( ax.xaxis.get_majorticklabels(), rotation=60 )
ax.legend(loc='upper center', bbox_to_anchor=(1.35, 1.05),
ncol=1, fancybox=True, shadow=True)
<matplotlib.legend.Legend at 0x7f96c9966dd8>
seaborn
¶Fancy plots and quick analysis
import seaborn as sns
f,ax = plt.subplots()
sns.boxplot(data=df, x=df.Date.dt.year, y='Cash',ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7f96d00e09b0>
df.sort_values('Cash', ascending=False)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
278 | Eglinton (Timber Products) Ltd | 2013-10-05 | BT47 | Solid Biomass Boiler | 990.0 | 252844.05 |
548 | McIlroy Farms Limited | 2013-05-09 | BT51 | Solid Biomass Boiler | 90.0 | 127605.27 |
333 | Green Biomass Ltd | 2014-04-11 | BT82 | Solid Biomass Boiler | 99.0 | 119012.29 |
672 | Paul Hobson Ltd | 2013-07-08 | BT71 | Solid Biomass Boiler | 99.0 | 112267.25 |
547 | McIlroy Farms Limited | 2014-03-11 | BT51 | Solid Biomass Boiler | 99.0 | 109827.91 |
671 | Paul Hobson Ltd | 2014-03-28 | BT71 | Solid Biomass Boiler | 99.0 | 100857.06 |
639 | Noel Smith Ltd | 2014-10-12 | BT70 | Solid Biomass Boiler | 99.0 | 95380.24 |
546 | McIlroy Farms Limited | 2014-09-29 | BT51 | Solid Biomass Boiler | 99.0 | 94584.81 |
545 | McIlroy Farms Limited | 2014-09-29 | BT51 | Solid Biomass Boiler | 99.0 | 94300.80 |
105 | C&L Mushrooms Ltd | 2013-09-02 | BT34 | Solid Biomass Boiler | 99.0 | 93080.70 |
638 | Noel Smith Ltd | 2014-10-12 | BT70 | Solid Biomass Boiler | 99.0 | 92151.89 |
318 | Glenavon House Hotel (1982) Ltd | 2014-09-20 | BT80 | Solid Biomass Boiler | 99.0 | 86210.69 |
91 | Bridge Mushrooms Ltd | 2013-09-01 | BT34 | Solid Biomass Boiler | 99.0 | 85823.50 |
353 | GSM Farms Ltd | 2014-10-24 | BT68 | Solid Biomass Boiler | 99.0 | 84687.61 |
605 | MP Poultry Ltd | 2015-02-01 | BT70 | Solid Biomass Boiler | 99.0 | 84296.87 |
104 | C&L Mushrooms Ltd | 2013-05-30 | BT34 | Solid Biomass Boiler | 99.0 | 84285.55 |
38 | Ballindarragh Poultry Farm Ltd | 2014-11-02 | BT60 | Solid Biomass Boiler | 99.0 | 82886.35 |
482 | Legmore Farms Ltd | 2014-06-30 | BT67 | Solid Biomass Boiler | 99.0 | 82006.17 |
604 | MP Poultry Ltd | 2015-02-01 | BT70 | Solid Biomass Boiler | 99.0 | 81279.24 |
317 | Glenavon House Hotel (1982) Ltd | 2014-03-25 | BT80 | Solid Biomass Boiler | 99.0 | 80899.44 |
314 | Future Fuels NI Ltd | 2014-11-06 | BT94 | Solid Biomass Boiler | 99.0 | 78402.51 |
354 | GSM Farms Ltd | 2014-10-24 | BT68 | Solid Biomass Boiler | 99.0 | 78273.81 |
332 | Green Biomass Ltd | 2014-05-21 | BT82 | Solid Biomass Boiler | 99.0 | 77792.64 |
597 | Mountain View Farm Ltd | 2014-08-09 | BT77 | Solid Biomass Boiler | 99.0 | 76659.25 |
37 | Ballindarragh Poultry Farm Ltd | 2014-11-02 | BT60 | Solid Biomass Boiler | 99.0 | 76055.34 |
36 | Ballindarragh Poultry Farm Ltd | 2014-11-02 | BT60 | Solid Biomass Boiler | 99.0 | 75578.94 |
601 | Mountain View Farm Ltd | 2014-12-09 | BT77 | Solid Biomass Boiler | 99.0 | 74162.41 |
35 | Ballindarragh Poultry Farm Ltd | 2014-11-02 | BT60 | Solid Biomass Boiler | 99.0 | 73523.77 |
481 | Legmore Farms Ltd | 2014-06-30 | BT67 | Solid Biomass Boiler | 99.0 | 73429.41 |
480 | Legmore Farms Ltd | 2014-06-30 | BT67 | Solid Biomass Boiler | 99.0 | 72381.60 |
... | ... | ... | ... | ... | ... | ... |
744 | Scott and Ewing LTD | 2015-11-11 | BT79 | Solid Biomass Boiler | 49.0 | 3699.40 |
788 | Spark Enterprises Ltd | 2015-11-03 | BT93 | Solid Biomass Boiler | 80.0 | 3648.16 |
644 | Oakgrove Cabins ltd | 2016-02-28 | BT47 | Solid Biomass Boiler | 40.0 | 3538.21 |
542 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 3529.52 |
623 | National Trust (The Argory) | 2015-11-01 | BA14 | Solid Biomass Boiler | 35.0 | 3448.73 |
156 | Corbally Poultry Farm Ltd | 2016-02-28 | BT32 | Solid Biomass Boiler | 50.0 | 3282.90 |
617 | National Trust (Florence Court) | 2015-05-28 | BA14 | Solid Biomass Boiler | 36.0 | 3148.25 |
646 | Oakra Hardwood Flooring ltd | 2015-11-16 | BT61 | Solid Biomass Boiler | 60.0 | 3045.65 |
571 | Millar Woodcraft Specialist Joinery Manufactur... | 2015-10-18 | BT41 | Solid Biomass Boiler | 25.0 | 2831.92 |
652 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 2646.34 |
651 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 2613.62 |
221 | Department of Agriculture and Rural Affairs (L... | 2015-04-10 | BT04 | Solid Biomass Boiler | 129.0 | 2601.15 |
787 | Spark Enterprises Ltd | 2015-11-03 | BT93 | Solid Biomass Boiler | 80.0 | 2537.86 |
782 | Spa Nursing Homes Ltd | 2016-02-28 | BT05 | Solid Biomass Boiler | 199.0 | 2506.53 |
748 | SDC Trailers Ltd | 2015-07-16 | BT41 | Solid Biomass Boiler | 99.0 | 2477.47 |
627 | Natural Waste Management Ltd | 2016-02-24 | BT60 | Solid Biomass Boiler | 60.0 | 2363.93 |
32 | Balcas Timber Ltd | 2016-02-27 | BT94 | Solid Biomass Boiler | 49.0 | 2235.47 |
181 | CRANN ENERGY LTD | 2016-02-27 | BT92 | Solid Biomass Boiler | 50.0 | 2057.80 |
541 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 1945.81 |
340 | Green Energy Engineering (GEE) Ltd | 2015-08-25 | BT66 | Solid Biomass Boiler | 40.0 | 1897.92 |
342 | Green Energy Engineering (GEE) Ltd | 2015-11-09 | BT25 | Solid Biomass Boiler | 25.0 | 1662.33 |
594 | Mosshill Services Ltd | 2015-11-16 | BT41 | Solid Biomass Boiler | 99.0 | 1120.00 |
388 | Heron Bros Ltd | 2014-06-04 | BT45 | Solid Biomass Boiler | 95.0 | 825.11 |
650 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 650.04 |
540 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 627.91 |
341 | Green Energy Engineering (GEE) Ltd | 2016-02-29 | BT25 | Solid Biomass Boiler | 25.0 | 603.65 |
389 | Heron Bros Ltd | 2014-02-27 | BT45 | Solid Biomass Boiler | 48.0 | 566.87 |
338 | Green Energy Engineering (GEE) Ltd | 2014-03-24 | BT25 | Solid Biomass Boiler | 25.0 | 288.02 |
339 | Green Energy Engineering (GEE) Ltd | 2015-08-24 | BT66 | Solid Biomass Boiler | 15.0 | 134.09 |
822 | Tri Met Engineering Ltd | 2015-11-09 | BT80 | Solid Biomass Boiler | 99.0 | 73.22 |
874 rows × 6 columns
df[df.Date>=pd.Timestamp('2015/10/01')].sort_values('Cash', ascending=False)
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
180 | Crann Energy Ltd | 2015-10-12 | BT92 | Solid Biomass Boiler | 99.0 | 65453.82 |
681 | PM Processing Ltd | 2015-10-14 | BT92 | Solid Biomass Boiler | 99.0 | 64595.05 |
680 | PM Processing Ltd | 2015-10-02 | BT92 | Solid Biomass Boiler | 99.0 | 59385.45 |
404 | Inish Glow Ltd | 2015-10-26 | BT92 | Solid Biomass Boiler | 99.0 | 57683.51 |
676 | Peacock Farms Poultry Ltd | 2015-10-14 | BT82 | Solid Biomass Boiler | 99.0 | 56757.26 |
677 | Peacock Farms Poultry Ltd | 2015-10-14 | BT82 | Solid Biomass Boiler | 99.0 | 56489.45 |
267 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 56102.54 |
406 | Inish Glow Ltd | 2015-10-26 | BT92 | Solid Biomass Boiler | 99.0 | 55963.95 |
405 | Inish Glow Ltd | 2015-10-26 | BT92 | Solid Biomass Boiler | 99.0 | 55401.57 |
266 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 54811.50 |
265 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 54588.17 |
843 | Valley Services (NI) Ltd | 2015-10-26 | BT74 | Solid Biomass Boiler | 99.0 | 54528.59 |
264 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 54335.46 |
516 | McAleer Farms Ltd | 2015-10-01 | BT78 | Solid Biomass Boiler | 99.0 | 54198.86 |
674 | Peacock Farms Poultry Ltd | 2015-10-14 | BT82 | Solid Biomass Boiler | 99.0 | 54188.21 |
675 | Peacock Farms Poultry Ltd | 2015-10-14 | BT82 | Solid Biomass Boiler | 99.0 | 54155.28 |
277 | Eglinton (Timber Products) Ltd | 2015-10-29 | BT47 | Solid Biomass Boiler | 99.0 | 54012.23 |
519 | McAleer Farms Ltd | 2015-10-01 | BT78 | Solid Biomass Boiler | 99.0 | 53886.84 |
800 | Stephens Catering Equipment Co Ltd | 2015-10-09 | BT94 | Solid Biomass Boiler | 99.0 | 53637.02 |
375 | Hegan Farms Ltd | 2015-10-14 | BT71 | Solid Biomass Boiler | 99.0 | 53598.97 |
842 | Valley Services (NI) Ltd | 2015-10-26 | BT74 | Solid Biomass Boiler | 99.0 | 53173.83 |
673 | Peacock Farms Poultry Ltd | 2015-10-14 | BT82 | Solid Biomass Boiler | 99.0 | 53126.92 |
263 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 52866.19 |
417 | JC Donald Ltd | 2015-11-09 | BT32 | Solid Biomass Boiler | 99.0 | 52394.99 |
797 | Stephens Catering Equipment Co Ltd | 2015-10-09 | BT94 | Solid Biomass Boiler | 99.0 | 52295.96 |
376 | Hegan Farms Ltd | 2015-10-14 | BT71 | Solid Biomass Boiler | 99.0 | 52034.92 |
798 | Stephens Catering Equipment Co Ltd | 2015-10-09 | BT94 | Solid Biomass Boiler | 99.0 | 51967.73 |
841 | Valley Services (NI) Ltd | 2015-10-26 | BT74 | Solid Biomass Boiler | 99.0 | 51878.77 |
718 | RJ Smyth Engineering Ltd. | 2015-10-27 | BT78 | Solid Biomass Boiler | 95.0 | 51757.03 |
262 | Ecobiomass NI Ltd | 2015-10-26 | BT71 | Solid Biomass Boiler | 99.0 | 51670.65 |
... | ... | ... | ... | ... | ... | ... |
197 | Curtis Developments Ltd T/A Curtis Toyota | 2016-02-26 | BT42 | Solid Biomass Boiler | 198.0 | 5170.90 |
146 | Cloughbane Farm Foods Ltd | 2016-02-29 | BT70 | Solid Biomass Boiler | 99.0 | 5123.75 |
179 | Craigfad Farm Limited | 2016-02-23 | BT44 | Solid Biomass Boiler | 199.0 | 4672.96 |
106 | C&L Mushrooms Ltd | 2016-02-29 | BT34 | Solid Biomass Boiler | 560.0 | 4670.33 |
789 | Spark Enterprises Ltd | 2015-11-03 | BT93 | Solid Biomass Boiler | 80.0 | 4579.43 |
194 | Culmore Energy | 2015-11-10 | BT49 | Solid Biomass Boiler | 99.0 | 4332.12 |
874 | Woodvale Construction Company Ltd | 2015-11-09 | BT79 | Solid Biomass Boiler | 49.0 | 4138.04 |
696 | R&S Biomass Equipment Ltd | 2015-11-14 | BT78 | Solid Biomass Boiler | 99.0 | 3707.65 |
744 | Scott and Ewing LTD | 2015-11-11 | BT79 | Solid Biomass Boiler | 49.0 | 3699.40 |
788 | Spark Enterprises Ltd | 2015-11-03 | BT93 | Solid Biomass Boiler | 80.0 | 3648.16 |
644 | Oakgrove Cabins ltd | 2016-02-28 | BT47 | Solid Biomass Boiler | 40.0 | 3538.21 |
542 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 3529.52 |
623 | National Trust (The Argory) | 2015-11-01 | BA14 | Solid Biomass Boiler | 35.0 | 3448.73 |
156 | Corbally Poultry Farm Ltd | 2016-02-28 | BT32 | Solid Biomass Boiler | 50.0 | 3282.90 |
646 | Oakra Hardwood Flooring ltd | 2015-11-16 | BT61 | Solid Biomass Boiler | 60.0 | 3045.65 |
571 | Millar Woodcraft Specialist Joinery Manufactur... | 2015-10-18 | BT41 | Solid Biomass Boiler | 25.0 | 2831.92 |
652 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 2646.34 |
651 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 2613.62 |
787 | Spark Enterprises Ltd | 2015-11-03 | BT93 | Solid Biomass Boiler | 80.0 | 2537.86 |
782 | Spa Nursing Homes Ltd | 2016-02-28 | BT05 | Solid Biomass Boiler | 199.0 | 2506.53 |
627 | Natural Waste Management Ltd | 2016-02-24 | BT60 | Solid Biomass Boiler | 60.0 | 2363.93 |
32 | Balcas Timber Ltd | 2016-02-27 | BT94 | Solid Biomass Boiler | 49.0 | 2235.47 |
181 | CRANN ENERGY LTD | 2016-02-27 | BT92 | Solid Biomass Boiler | 50.0 | 2057.80 |
541 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 1945.81 |
342 | Green Energy Engineering (GEE) Ltd | 2015-11-09 | BT25 | Solid Biomass Boiler | 25.0 | 1662.33 |
594 | Mosshill Services Ltd | 2015-11-16 | BT41 | Solid Biomass Boiler | 99.0 | 1120.00 |
650 | O'Neill's Irish International Sportswear Ltd | 2016-02-23 | BT82 | Solid Biomass Boiler | 95.0 | 650.04 |
540 | McGrane Nurseries Ltd | 2016-02-19 | BT62 | Solid Biomass Boiler | 199.0 | 627.91 |
341 | Green Energy Engineering (GEE) Ltd | 2016-02-29 | BT25 | Solid Biomass Boiler | 25.0 | 603.65 |
822 | Tri Met Engineering Ltd | 2015-11-09 | BT80 | Solid Biomass Boiler | 99.0 | 73.22 |
507 rows × 6 columns
con_df.groupby('Company').sum().plot.scatter(x="Capacity (kWtH)",y="Cash")
<matplotlib.axes._subplots.AxesSubplot at 0x7f96c9f06c88>
f,ax = plt.subplots()
sns.regplot(x="Capacity (kWtH)",y="Cash", data=con_df.groupby('Company').sum(), ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7f96c974fef0>
sns.jointplot(x="Capacity (kWtH)",y="Cash", data=con_df.groupby('Company').sum(), kind='reg')
<seaborn.axisgrid.JointGrid at 0x7f96c9778470>
company_df = con_df.groupby('Company').sum()
company_df['N'] = con_df.groupby('Company').size()
company_df['Cash Per Cap.'] = company_df['Cash']/company_df['Capacity (kWtH)']
company_df.sort_values('Cash Per Cap.', ascending=False)
##http://www.newsletter.co.uk/news/farmer-who-got-660k-for-13-rhi-boilers-says-only-80k-was-profit-1-7870639
Capacity (kWtH) | Cash | N | Cash Per Cap. | |
---|---|---|---|---|
Company | ||||
Green Biomass Ltd | 198.0 | 196804.93 | 2 | 993.964293 |
Noel Smith Ltd | 198.0 | 187532.13 | 2 | 947.131970 |
McIlroy Farms Limited | 585.0 | 513312.78 | 6 | 877.457744 |
Glenavon House Hotel (1982) Ltd | 198.0 | 167110.13 | 2 | 843.990556 |
MP Poultry Ltd | 297.0 | 234159.54 | 3 | 788.415960 |
Legmore Farms Ltd | 396.0 | 293496.26 | 4 | 741.152172 |
GSM Farms Ltd | 297.0 | 219257.87 | 3 | 738.241987 |
Ballindarragh Poultry Farm Ltd | 594.0 | 432282.88 | 6 | 727.748956 |
Moore (Unidrill) Ltd | 99.0 | 71804.01 | 1 | 725.293030 |
Paul Hobson Ltd | 963.0 | 659540.81 | 13 | 684.881423 |
Mountain View Farm Ltd | 693.0 | 471971.94 | 7 | 681.056190 |
Sean & Kathleen Kerr Ltd | 396.0 | 266933.00 | 4 | 674.073232 |
Future Fuels NI Ltd | 388.0 | 258031.77 | 4 | 665.030335 |
Crann Energy Ltd | 99.0 | 65453.82 | 1 | 661.149697 |
Damiraco Ltd | 99.0 | 64016.50 | 1 | 646.631313 |
Easibility Showers Ltd | 80.0 | 51006.83 | 1 | 637.585375 |
Moore Unidrill Ltd | 99.0 | 62881.21 | 1 | 635.163737 |
Clinty Chemicals Limited | 99.0 | 62572.80 | 1 | 632.048485 |
Cap Farms Ltd | 198.0 | 124839.71 | 2 | 630.503586 |
PM Processing Ltd | 198.0 | 123980.50 | 2 | 626.164141 |
Ballyclare Golf Club | 97.0 | 58093.46 | 1 | 598.901649 |
Morrow Contracts Ltd | 97.0 | 56876.00 | 1 | 586.350515 |
Rafferty Poultry Ltd | 297.0 | 173373.49 | 3 | 583.749125 |
RW Pierce Group Ltd | 99.0 | 57728.22 | 1 | 583.113333 |
Fairlawns Care Home Ltd | 99.0 | 57711.01 | 1 | 582.939495 |
Inish Glow Ltd | 297.0 | 169049.03 | 3 | 569.188653 |
Grove Cottage Farm Ltd | 198.0 | 112152.24 | 2 | 566.425455 |
Henry Sinnamon Ltd | 297.0 | 165135.22 | 3 | 556.010842 |
Peacock Farms Poultry Ltd | 495.0 | 274717.12 | 5 | 554.984081 |
Renewable Heat Generation Limited | 360.0 | 194669.59 | 4 | 540.748861 |
... | ... | ... | ... | ... |
O'Neill's Irish International Sportswear Ltd | 570.0 | 32668.55 | 6 | 57.313246 |
Cloughbane Farm Foods Ltd | 99.0 | 5123.75 | 1 | 51.755051 |
Drumlea poultry Ltd | 199.0 | 10195.16 | 1 | 51.231960 |
Oakra Hardwood Flooring ltd | 60.0 | 3045.65 | 1 | 50.760833 |
John Mulholland Motors Ltd | 149.0 | 7493.48 | 1 | 50.291812 |
Donaghmore District Community Association (DDCA) | 199.0 | 9656.04 | 1 | 48.522814 |
Mc. Don Peat Supplies Ltd | 198.0 | 9132.09 | 1 | 46.121667 |
Moy Park Ltd | 398.0 | 18141.63 | 2 | 45.581985 |
Hazelburn Poultry Ltd | 234.0 | 10420.85 | 2 | 44.533547 |
SEK Limited | 398.0 | 17654.97 | 2 | 44.359221 |
B-Cam Poultry Ltd. | 199.0 | 8806.74 | 1 | 44.254975 |
Culmore Energy | 99.0 | 4332.12 | 1 | 43.758788 |
Carella Laminate Systems Ltd | 160.0 | 6908.97 | 1 | 43.181063 |
Sainsbury's (Craigavon) | 580.0 | 24221.85 | 1 | 41.761810 |
DS Farms Ltd | 199.0 | 8248.35 | 1 | 41.448995 |
CRANN ENERGY LTD | 50.0 | 2057.80 | 1 | 41.156000 |
Mosshill Services Ltd | 198.0 | 8110.92 | 2 | 40.964242 |
D&O Poultry Ltd. | 199.0 | 7889.70 | 1 | 39.646734 |
Meegan Enterprises Ltd | 199.0 | 7842.02 | 1 | 39.407136 |
McMenamin Poultry Ltd | 199.0 | 7685.80 | 1 | 38.622111 |
Department of Agriculture and Rural Development (Enniskillen College) | 300.0 | 11583.97 | 1 | 38.613233 |
McGrane Nurseries Ltd | 997.0 | 35789.74 | 4 | 35.897432 |
Norhil Poultry Ltd | 199.0 | 6750.79 | 1 | 33.923568 |
Rowan Renewables Ltd | 199.0 | 5959.55 | 1 | 29.947487 |
W & A Nixon & Sons Ltd | 199.0 | 5682.95 | 1 | 28.557538 |
Cash Hill Farm Ltd | 198.0 | 5561.82 | 1 | 28.090000 |
Curtis Developments Ltd T/A Curtis Toyota | 198.0 | 5170.90 | 1 | 26.115657 |
Craigfad Farm Limited | 398.0 | 10249.93 | 2 | 25.753593 |
Department of Agriculture and Rural Affairs (Loughry College) | 477.0 | 11964.84 | 2 | 25.083522 |
Daly Poultry Ltd. | 999.0 | 15795.00 | 1 | 15.810811 |
403 rows × 4 columns
cufflinks
¶Fancy interactive plotting with plotly
import cufflinks
con_df.groupby(pd.TimeGrouper(key='Date',freq='M'))['Cash'].sum()\
.iplot()
_con_df_month_con=con_df.groupby([pd.TimeGrouper(key='Date',freq='M'),'Constituency'])['Cash'].sum().unstack()
_con_df_month_con.iplot()
# https://plot.ly/~bolster/211
_con_df_month_con.iplot(kind='bar',
barmode='stack',
filename='pybfs-stackedbar',
world_readable=True)
_con_df_month_con.iplot(kind='heatmap',colorscale='spectral')
_con_df_month_con.head()
Constituency | Belfast West | East Londonderry | Fermanagh and South Tyrone | Foyle | Lagan Valley | Mid Ulster | Newry and Armagh | North Antrim | North Down | South Antrim | South Down | Strangford | Upper Bann | West Tyrone |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Date | ||||||||||||||
2013-01-31 | NaN | NaN | 64016.5 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 6995.34 | NaN | NaN | NaN |
2013-02-28 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 27822.92 | NaN | NaN | NaN | 19873.24 |
2013-03-31 | 37234.47 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 38638.25 |
2013-04-30 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 26159.07 | NaN | NaN | NaN | NaN | NaN | NaN |
2013-05-31 | NaN | NaN | NaN | 51611.56 | NaN | 172751.55 | NaN | NaN | NaN | NaN | NaN | NaN | 84285.55 | 58044.85 |
_con_df_month_con.sum().sort_values(ascending=False)
Constituency West Tyrone 6907832.38 Upper Bann 5805621.25 Fermanagh and South Tyrone 3700088.66 Mid Ulster 2935951.53 Newry and Armagh 2626124.01 South Antrim 2255495.91 North Antrim 947731.44 Strangford 430424.07 South Down 377549.61 East Londonderry 290763.19 Belfast West 257127.67 Lagan Valley 251102.55 Foyle 122952.19 North Down 69649.89 dtype: float64
_con_df_month_con[_con_df_month_con.sum().sort_values(ascending=False).index]\
.iplot(kind='heatmap',colorscale='spectral', filename='pybfs-heatmap',world_readable=True)
from tqdm import tqdm, tqdm_notebook, tqdm_pandas, tnrange
from time import sleep
for j in tqdm_notebook(range(100), desc='2nd loop'):
sleep(0.01)
_df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
tn=tqdm_notebook()
tn.pandas(desc='Wrong kind of bar')
def worker(value):
sleep(0.1)
return value.sum()
_df.progress_apply(worker)
0 4965741 1 4942046 2 4950718 3 4953369 4 4952529 5 4924638 dtype: int64
_df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))
tn=tqdm_notebook()
tn.pandas(desc='Wrong kind of bar')
def worker(value):
sleep(0.1)
if not value.sum()%10:
tn.write('Teven')
return value.sum()
_df.progress_apply(worker)
0 4951711 1 4944459 2 4952761 3 4938116 4 4951176 5 4951085 dtype: int64
df[df.Company.str.contains('urch')]
Company | Date | Postcode | Type | Capacity (kWtH) | Cash | |
---|---|---|---|---|---|---|
39 | Ballinderry Parish Church Hall | 2015-10-27 | BT28 | Solid Biomass Boiler | 40.0 | 7128.37 |
87 | Brantry Church | 2015-08-05 | BT70 | Solid Biomass Boiler | 80.0 | 15291.60 |
251 | Dundrod Presbyterian Church | 2015-10-29 | BT29 | Solid Biomass Boiler | 99.0 | 14421.57 |
268 | Edengrove Presbyterian Church | 2015-10-28 | BT24 | Solid Biomass Boiler | 99.0 | 9490.41 |
373 | Hebron Free Presbyterian Church | 2015-02-03 | BT53 | Solid Biomass Boiler | 99.0 | 39023.77 |
374 | Hebron Free Presbyterian Church | 2015-10-19 | BT53 | Solid Biomass Boiler | 60.0 | 19914.29 |
394 | Hillsborough Parish Church | 2015-03-06 | BT26 | Solid Biomass Boiler | 40.0 | 7461.59 |
395 | Hillsborough Parish Church | 2013-11-11 | BT26 | Solid Biomass Boiler | 80.0 | 31790.13 |
df.groupby('Company')['Capacity (kWtH)'].sum().sort_values(ascending=False).head()
Company Eglinton (Timber Products) Ltd 1584.0 John Hogg & Co Ltd 1188.0 Dennison Commercials Ltd 1089.0 Daly Poultry Ltd. 999.0 McGrane Nurseries Ltd 997.0 Name: Capacity (kWtH), dtype: float64
df.groupby('Company').size().sort_values(ascending=False).head()
Company Paul Hobson Ltd 13 John Hogg & Co Ltd 12 Dennison Commercials Ltd 11 McCaffrey Aggregates Ltd 10 Charles Hurst Ltd 10 dtype: int64
con_df[con_df.Date > pd.Timestamp('2015/09/28')].groupby('Constituency')['Cash'].sum().sort_values(ascending=False).plot.barh()
<matplotlib.axes._subplots.AxesSubplot at 0x7f96c9274d68>
# All-time ratios of how much cash each constituency got
con_ratio = con_df.groupby('Constituency')['Cash'].sum()/con_df['Cash'].sum()
# October/November/December 2015 ratios of how much cash each constituency got
nov_con_ratio = con_df[con_df.Date > pd.Timestamp('2015/09/28')].groupby('Constituency')['Cash'].sum()/con_df[con_df.Date > pd.Timestamp('2015/09/28')]['Cash'].sum()
# How much each constituency increased above their normal application cost ratio in the final months of RHI
pd.concat([con_ratio, nov_con_ratio], keys=['fuggit','this'], axis=1).diff(axis=1)['this'].plot.barh()
<matplotlib.axes._subplots.AxesSubplot at 0x7f96c94f92b0>
con_df.to_hdf('datastore.h5','original')
/home/bolster/anaconda3/lib/python3.5/site-packages/pandas/core/generic.py:1138: PerformanceWarning: your performance may suffer as PyTables will pickle object types that it cannot map directly to c-types [inferred_type->mixed,key->block2_values] [items->['Company', 'Postcode', 'Type', 'Constituency']]