Skip to main content

ESNEFT Analysis - Diabetes Inequalities

status: experimental

Table of contents

Installation

Installation is possible via pip as shown below.

Unix/macOS

python3 -m pip install esneft_tools

Windows

py -m pip install esneft_tools

Install within a Virtual Environment (optional)

Unix/macOS
python -m venv esneft_tools
source esneft_tools/bin/activate
python3 -m pip install esneft_tools
Windows
py -m venv esneft_tools
esneft_tools/Scripts/Activate.ps1
py -m pip install esneft_tools

If running scripts is disabled on your system then run the following command before activating your environment.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Geospatial Dependencies (optional)

Additional geospatial utilities may be optionally installed as below. Note these packages have non-trivial dependencies and automatic installation may not work on all systems.

An additional optional dependency, OSMnx, must be installed by the user. Please refer to the OSMnx documentation for further installation instructions.

Clear here for code

Unix/macOS

python3 -m pip install esneft_tools[geo]

Windows

py -m pip install esneft_tools[geo]

Setup

The logging level of esneft_tools can be set via the setVerbosity() function.

import logging
from esneft_tools.utils import setVerbosity
from esneft_tools import download, process, visualise

setVerbosity(logging.INFO)

Retrieve Public Data

Download

From Host

Each of the esneft_tools.download.getData().fromHost() functions retrieve a static copy of a particular data set from GitHub. A local copy of these tables is saved to ./.data-cache/ by default. Each can be obtained individually but it is recommended to retrieve all data, as below.

# Instantiate data download class.
getData = download.getData(cache='./.data-cache')

# Retrieve all data as dictionary (recommended)
data = getData.fromHost('all')
  • all (default)
    • Retrieve all of the below data in dictionary format (recommended).
  • postcodeLSOA
  • Postcode -> LSOA (2011) lookup Table from ArcGIS
  • imdLSOA
  • Indices of Deprivation by LSOA in England from National Statistics (.gov.uk)
  • populationLSOA
  • LSOA population estimates, by age and sex, from ONS
  • ethnicityLSOA
    • Proportion of ethnicity minorities (non-white) by LSOA from NOMIS
  • areaLSOA
  • Land hectare measures by LSOA from ArcGIS
  • gpRegistration
  • gpPractice
  • gpStaff
  • qof
    • Quality and Outcomes Framework, 2021-22 from NHS Digital
  • geoLSOA
  • esneftLSOA
    • List of LSOAs within ESNEFT trust.
  • esneftOSM
    • OpenStreetMap (OSM) data for ESNEFT area from Geofabrik

From Source

Alternatively, the .fromSource() method can be used to retrieve each dataset directly from its public source. By default, esneft_tools will retrieve the source data that matches the fromHost() methods. Each source URL can be updated to newer versions by providing a YAML file to download.getData() as shown below. An example of the YAML file is shown here.

Clear here for code
# Instantiate data download class.
getData = download.getData(sourceURL='sourceURL.yaml', cache='./.data-cache')

# Retrieve a specific dataset from host.
# Note: "all" does not work with .fromSource().
imdLSOA = getData.fromSource('imdLSOA')

Processing

Aggregate by Practice Level

The getGPsummary function aggregates the downloaded data to practice level statistics.

GPsummary = process.getGPsummary(**data, iod_cols='IMD')
Field Description
OrganisationCode Practice Service Code
IMD Mean Index of Multiple Deprivation of Registered Patients
Patient Total Registered Patients
QOF-DM QOF achievement for Diabetes mellitus (max 76)
DM-prevalance Prevalence of Diabetes mellitus
PCDS Postcode
OpenDate Opening Date
CloseDate Closing Date
Status Service Status (e.g. Active)
PrescribingSetting Service Type (e.g. GP Practice)
currentStaff Current Practitioners
departedStaff Total Departed Practitioners
meanStaff Average Working Practitioners
annualStaffTurnover Mean Annual % Practitioner Turnover
Lat Latitude of Site
Long Longitude of Site
patientPerGP Total Registered Patient per Average Practitioner Count
ESNEFT Boolean Flag of Practices within ESNEFT
Node Closest OSM Map Node to Site

Aggregate by LSOA Level

The getLSOAsummary function aggregates the downloaded data LSOA level statistics.

LSOAsummary = process.getLSOAsummary(**data, iod_cols='IMD')
Field Description
LSOA11CD LSOA (2011) Code
LSOA11NM LSOA (2011) Name
Age (median) Median Age of Population
Population Population Estimate (2011 Census)
LandHectare Land Area (Hectares)
Patient Total Registered GP Patients
IMD Index of Multiple Deprivation
IMD (q5) Index of Multiple Deprivation (quintiles)
DM-prevalance Prevalence of Diabetes mellitus
Density Population Density
ESNEFT Boolean Flag of LSOAs within ESNEFT

Visualise

Practice Map

fig = visualise.scatterGP(GPsummary[GPsummary['Status'] == 'Active'], minCount=250)

gp-loc
Map of Practice Distributions within ESNEFT (Plotly Interactive)

LSOA Map

fig = visualise.choroplethLSOA(LSOAsummary, data['geoLSOA'], colour='IMD')

gp-loc
Choropleth Map of LSOA Domains within ESNEFT coloured by IMD (Plotly Interactive)

Further Documentation

Refer to the additional documentation for further examples of functionality.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidance.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

If you have any other questions please contact the author, Stephen Richer.

Metadata

Release files for esneft-tools 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for esneft-tools 0.1.4
File Size Uploaded Provenance Actions
esneft_tools-0.1.4.tar.gz 23.6 kB Without provenance Details for esneft_tools-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for esneft-tools 0.1.4
File Interpreter ABI Platform Actions
esneft_tools-0.1.4-py3-none-any.whl Python 3 none any Details for esneft_tools-0.1.4-py3-none-any.whl

Total release size: 45.2 kB

Release files / esneft_tools-0.1.4.tar.gz

Download URL esneft_tools-0.1.4.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
14fcd8e30a25574f30074f565646e5e89425096f0f7cb950e9c1d09fdc45e05c
BLAKE2b-256 checksum
How to use checksums
77ec2c5e2fb48c35b872e82ca2aa762f7944294ca15002c3f24fa5047179b3ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / esneft_tools-0.1.4-py3-none-any.whl

Download URL esneft_tools-0.1.4-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f97626aa677e2633fc5c8f378d70cbb46cc98d04af8024116899f73423f5492
BLAKE2b-256 checksum
How to use checksums
522261f52806208e94fff7cca0652bd82f5e1d09b6b843ad1d90322de42d2eca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Security for esneft-tools 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page