Created
November 24, 2019 13:37
-
-
Save psychemedia/6cc856b3424658612f318ae93d091f96 to your computer and use it in GitHub Desktop.
NHS car parking revenues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# The Costs and Revenues Associated With Running a Hospital - Parking\n", | |
"\n", | |
"How much does it cost to run a hospital, and what revenue streams are available to hospitals to help them raise money at a local level?\n", | |
"\n", | |
"The NHS Estates Returns Information Collection (ERIC) seems to provide cost reports at local level and income reports at trust level.\n", | |
"\n", | |
"\n", | |
"Data link via [Owen Boswarva](https://www.owenboswarva.com/)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Trust Code</th>\n", | |
" <th>Trust Name</th>\n", | |
" <th>Old Commissioning Region</th>\n", | |
" <th>New Commissioning Region</th>\n", | |
" <th>Trust Type</th>\n", | |
" <th>Number of sites - General acute hospital (No.)</th>\n", | |
" <th>Number of sites - Specialist hospital (acute only) (No.)</th>\n", | |
" <th>Number of sites - Mixed service hospital (No.)</th>\n", | |
" <th>Number of sites - Mental Health (including Specialist services) (No.)</th>\n", | |
" <th>Number of sites - Learning Disabilities (No.)</th>\n", | |
" <th>...</th>\n", | |
" <th>Fires recorded (No.)</th>\n", | |
" <th>False alarms - No call out (No.)</th>\n", | |
" <th>False alarms - Call out (No.)</th>\n", | |
" <th>Number of deaths resulting from fire(s) (No.)</th>\n", | |
" <th>Number of people injured resulting from fire(s) (No.)</th>\n", | |
" <th>Number of patients sustaining injuries during evacuation (No.)</th>\n", | |
" <th>Medical Records cost - Onsite (£)</th>\n", | |
" <th>Medical Records cost - Offsite (£)</th>\n", | |
" <th>Type of Medical Records (Select)</th>\n", | |
" <th>Medical Records service provision (Select)</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>R0A</td>\n", | |
" <td>MANCHESTER UNIVERSITY NHS FOUNDATION TRUST</td>\n", | |
" <td>NORTH OF ENGLAND COMMISSIONING REGION</td>\n", | |
" <td>NORTH WEST COMMISSIONING REGION</td>\n", | |
" <td>ACUTE - TEACHING</td>\n", | |
" <td>3</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>0</td>\n", | |
" <td>...</td>\n", | |
" <td>15</td>\n", | |
" <td>0</td>\n", | |
" <td>334</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2,871,339</td>\n", | |
" <td>145,631</td>\n", | |
" <td>3. Mixed</td>\n", | |
" <td>Internal</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>R1A</td>\n", | |
" <td>WORCESTERSHIRE HEALTH AND CARE NHS TRUST</td>\n", | |
" <td>MIDLANDS AND EAST OF ENGLAND COMMISSIONING REGION</td>\n", | |
" <td>MIDLANDS COMMISSIONING REGION</td>\n", | |
" <td>COMMUNITY</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>1</td>\n", | |
" <td>5</td>\n", | |
" <td>1</td>\n", | |
" <td>...</td>\n", | |
" <td>3</td>\n", | |
" <td>7</td>\n", | |
" <td>7</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>169,347</td>\n", | |
" <td>118,345</td>\n", | |
" <td>3. Mixed</td>\n", | |
" <td>Hybrid</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>R1C</td>\n", | |
" <td>SOLENT NHS TRUST</td>\n", | |
" <td>SOUTH OF ENGLAND COMMISSIONING REGION</td>\n", | |
" <td>SOUTH EAST COMMISSIONING REGION</td>\n", | |
" <td>COMMUNITY</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>...</td>\n", | |
" <td>1</td>\n", | |
" <td>35</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>39,584</td>\n", | |
" <td>83,204</td>\n", | |
" <td>3. Mixed</td>\n", | |
" <td>Hybrid</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>3 rows × 55 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Trust Code Trust Name \\\n", | |
"0 R0A MANCHESTER UNIVERSITY NHS FOUNDATION TRUST \n", | |
"1 R1A WORCESTERSHIRE HEALTH AND CARE NHS TRUST \n", | |
"2 R1C SOLENT NHS TRUST \n", | |
"\n", | |
" Old Commissioning Region \\\n", | |
"0 NORTH OF ENGLAND COMMISSIONING REGION \n", | |
"1 MIDLANDS AND EAST OF ENGLAND COMMISSIONING REGION \n", | |
"2 SOUTH OF ENGLAND COMMISSIONING REGION \n", | |
"\n", | |
" New Commissioning Region Trust Type \\\n", | |
"0 NORTH WEST COMMISSIONING REGION ACUTE - TEACHING \n", | |
"1 MIDLANDS COMMISSIONING REGION COMMUNITY \n", | |
"2 SOUTH EAST COMMISSIONING REGION COMMUNITY \n", | |
"\n", | |
" Number of sites - General acute hospital (No.) \\\n", | |
"0 3 \n", | |
"1 0 \n", | |
"2 0 \n", | |
"\n", | |
" Number of sites - Specialist hospital (acute only) (No.) \\\n", | |
"0 4 \n", | |
"1 0 \n", | |
"2 0 \n", | |
"\n", | |
" Number of sites - Mixed service hospital (No.) \\\n", | |
"0 1 \n", | |
"1 1 \n", | |
"2 1 \n", | |
"\n", | |
" Number of sites - Mental Health (including Specialist services) (No.) \\\n", | |
"0 3 \n", | |
"1 5 \n", | |
"2 0 \n", | |
"\n", | |
" Number of sites - Learning Disabilities (No.) ... Fires recorded (No.) \\\n", | |
"0 0 ... 15 \n", | |
"1 1 ... 3 \n", | |
"2 0 ... 1 \n", | |
"\n", | |
" False alarms - No call out (No.) False alarms - Call out (No.) \\\n", | |
"0 0 334 \n", | |
"1 7 7 \n", | |
"2 35 1 \n", | |
"\n", | |
" Number of deaths resulting from fire(s) (No.) \\\n", | |
"0 0 \n", | |
"1 0 \n", | |
"2 0 \n", | |
"\n", | |
" Number of people injured resulting from fire(s) (No.) \\\n", | |
"0 0 \n", | |
"1 0 \n", | |
"2 1 \n", | |
"\n", | |
" Number of patients sustaining injuries during evacuation (No.) \\\n", | |
"0 0 \n", | |
"1 0 \n", | |
"2 0 \n", | |
"\n", | |
" Medical Records cost - Onsite (£) Medical Records cost - Offsite (£) \\\n", | |
"0 2,871,339 145,631 \n", | |
"1 169,347 118,345 \n", | |
"2 39,584 83,204 \n", | |
"\n", | |
" Type of Medical Records (Select) Medical Records service provision (Select) \n", | |
"0 3. Mixed Internal \n", | |
"1 3. Mixed Hybrid \n", | |
"2 3. Mixed Hybrid \n", | |
"\n", | |
"[3 rows x 55 columns]" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import pandas as pd\n", | |
"\n", | |
"url_trust = 'https://files.digital.nhs.uk/83/4AF81B/ERIC%20-%20201819%20-%20TrustData%20v4.csv'\n", | |
"\n", | |
"df_trust = pd.read_csv(url_trust, encoding='latin1')\n", | |
"df_trust.columns = [c.strip() for c in df_trust.columns]\n", | |
"df_trust.head(3)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "92ba11e47d8a4c06ba4c27eaff1dd727", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"interactive(children=(Dropdown(description='region', options=('NORTH WEST COMMISSIONING REGION', 'MIDLANDS COM…" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"cols = ['Income from car parking - patients and visitors (£)', 'Income from car parking - staff (£)']\n", | |
"\n", | |
"from ipywidgets import Dropdown, interact\n", | |
"\n", | |
"region_widget = Dropdown(options = df_trust['New Commissioning Region'].unique())\n", | |
"trust_widget = Dropdown()\n", | |
"\n", | |
"# Define a function that updates the content of y based on what we select for x\n", | |
"def update_trusts(*args):\n", | |
" trust_widget.options = df_trust[df_trust['New Commissioning Region']==region_widget.value]['Trust Name'].unique()\n", | |
" \n", | |
"region_widget.observe(update_trusts)\n", | |
"\n", | |
"# Some function you want executed\n", | |
"def trust_report(region, trust):\n", | |
" return df_trust[df_trust['Trust Name']==trust][['Trust Name']+cols]\n", | |
"\n", | |
"interact(trust_report, region = region_widget, trust = trust_widget);" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pandas | |
voila |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment