Skip to content

dfe-analytical-services/mp-lookup

MP lookup MP-lookup user guide

Repository that contains an up to date lookup of MPs, their constituencies, and their party affiliations.

This is a quick stop-gap, long term this will hopefully be made available from a database within DfE for analysts to access.

How to use

The look up file is available as a CSV file you can view and download from the repository. There's a user guide available as a webpage, and a user guide as a downloadable PDF to assist you in getting what you need from the lookup file.

If you want to use this lookup programmatically (e.g. R or Python), you can use the raw URL:

https://raw.githubusercontent.com/dfe-analytical-services/mp-lookup/refs/heads/main/mp_lookup.csv

Development dependencies

All packages used in this repo are based on the latest versions available, currently there is no package management in place.

To install the packages needed to run the code in this repository, run the commands that are used in the .github/workflows/run_data_update.yaml file.

Sources

The MP data is sourced from the UK Parliament API and the Open Geography Portal using the following R packages:

The election results data is sourced from the 'candidate-level general election result data' CSV file from the UK Parliament election results page.

Other related packages

Lookup files and boundary information over time can be found on the Open Geography Portal.

dfeR also provides a number of curated lookups for DfE analysts using R, including a get_ons_api_data() API wrapper for programmatically accessing static files from the the Open Geography Portal.

If you need anything else from the Open Geography Portal, or a direct connection to the latest data look at using the boundr package.

Updates

Updates about MPs are done automatically every Monday morning using GitHub Actions, these check for any changes in the MP data, and will overwrite the file with a newer version if there are.

Election results data is updated manually, and will be done when the next general election is called.

Documentation

The documentation is maintained in this README (largely aimed at maintainers) and user-guide.qmd (aimed at end users).

The user guide is kept as both a pdf and html version, with the html version being published to GitHub pages via an automated workflow.

If a manual deploy of the user guide to GitHub pages is ever required, this can be done using the following command in the Bash terminal:

quarto publish gh-pages user-guide.qmd

Updating the pdf is performed manually using the command:

quarto::quarto_render(
   "user-guide.qmd",
   output_format = "pdf",
   metadata = list(
      papersize = "A4",
      format=list(
         pdf=list(
            toc = TRUE, 
            `number-sections` = TRUE,
            mainfont="Arial"
         )
      )
   )
)

Contact and requests

If you have any questions, or requests for additional data or changes to the existing data, please raise an issue on this repository.

About

The DfE's MP - Parliamentary constituency look-up table and associated R code and workflows

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages