Skip to content

About

UK open data in Python for civil society, from charities and community groups to researchers and students.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

uk-open-data

UK open data in Python for civil society, from charities and community groups to researchers and students. Load public data from official sources, join it to your own, and get figures you can check. The first datasets are geographic boundaries, official statistics, postcodes and deprivation indices, with more on the way.

Made by KindTech UK. Up to version 0.1 the package was called kindtech.

What is in it

  • Data modules. uk_open_data.geo loads boundaries from the ONS Geoportal, uk_open_data.ons loads statistics from the Nomis API, uk_open_data.postcodes turns postcodes into geography codes, and uk_open_data.imd loads the deprivation indices. Bring your own DataFrame backend, pandas or polars.
  • Analyses. Each analysis answers one question a charity asks of its own data, such as "Are we reaching people in the most deprived neighbourhoods?". It returns totals, the working, the sources and what a person must check. Nothing in a result describes one person.
  • A command line. uk-open-data analysis run runs an analysis on a file without writing any Python.
  • A connector for chat assistants. The same analyses and data as tools for an assistant such as Claude or ChatGPT. The assistant sees totals, never rows.

These analyses follow work first done by DataKind UK volunteers with charities.

Installation

Install uk-open-data from PyPI:

uv add uk-open-data

The uk-open-data package includes uk_open_data.geo, uk_open_data.ons, uk_open_data.postcodes, and uk_open_data.imd. See the package FAQ for how these subpackages are installed and released together.

Quick start

import pandas as pd  # or polars

from uk_open_data import (
    geodata_to_properties,
    load_geodata,
    load_ons,
    postcodes_to_geography,
)

# Local authority boundaries from the ONS Geoportal
geojson = load_geodata(geography_type="LAD", year="2025", boundary_type="BUC")
areas = pd.DataFrame(geodata_to_properties(geojson, "LAD", 2025))

# Population of each local authority from Nomis: all persons, all ages
population = load_ons(
    "population",
    geography_type="LAD",
    time="latest",
    measures=20100,
    gender=0,
    c_age=200,
    select=["geography_code", "obs_value"],
)

# Every dataset has a geography_code column, so they join directly
areas = areas.merge(population, on="geography_code")

# Your own postcodes, placed in the same local authorities
located = postcodes_to_geography(["SE13 7HX", "SE6 4RU"], geography_type="LAD")
located.merge(population, on="geography_code")
#    postcode geography_code geography_name  obs_value
# 0  SE13 7HX      E09000023       Lewisham     301037
# 1   SE6 4RU      E09000023       Lewisham     301037

The user guide covers each module.

Examples

Interactive notebooks you can run in the browser:

Notebook Description
Open in molab Browse and load ONS datasets from the NOMIS API
Open in molab Explore UK geographic boundaries
Open in molab Join boundaries with statistics

Case studies

End-to-end reproductions of DataKind UK charity projects, each chaining several connectors on geography_code:

Notebook Case study
Open in molab Smart Works — women's unemployment vs service reach (Census 2021 + LAD boundaries)
Open in molab Citizens Advice Lewisham — deprivation vs service usage (postcodes + IMD + LSOA boundaries)
Open in molab Sobus — BAME mental-health referrals in Hammersmith & Fulham (outcodes + Census ethnicity)
Open in molab Starlight — hospital play provision vs need across ICBs
Open in molab Material Focus — travel time to the nearest recycling point (LAD boundaries + population)

See the case studies in the docs for the full write-ups and figures.

For students and researchers

The same loaders work for coursework, a dissertation or a research project. Each one fetches from an official source, and Data sources explains the APIs behind them. The notebooks above run in the browser with nothing to install.

Students and researchers are welcome to contribute: a new data source, a worked analysis, or a fix to the docs. Read the contributing guide and DEVELOPERS.md, then open an issue to say what you would like to work on.

Use it from an AI assistant

In Claude Code, install the plugin:

/plugin marketplace add KindTechUK/plugins
/plugin install uk-open-data@kindtech

For other assistants, the connector offers the analyses and data over the Model Context Protocol. Coding agents can read the docs as Markdown: llms.txt lists every page, and llms-full.txt holds them all in one file.

Development

See DEVELOPERS.md for development setup and workflow instructions.

Licence

Apache-2.0. See LICENSE and NOTICE. Version 0.1.0 was published under the MIT License; its notice is kept in NOTICE.

About

UK open data in Python for civil society, from charities and community groups to researchers and students.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages