uk-open-data 0.2.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. uk_open_data-0.2.0a1/LICENSE +202 -0
  2. uk_open_data-0.2.0a1/NOTICE +32 -0
  3. uk_open_data-0.2.0a1/PKG-INFO +188 -0
  4. uk_open_data-0.2.0a1/README.md +153 -0
  5. uk_open_data-0.2.0a1/pyproject.toml +109 -0
  6. uk_open_data-0.2.0a1/setup.cfg +4 -0
  7. uk_open_data-0.2.0a1/src/uk_open_data/__init__.py +39 -0
  8. uk_open_data-0.2.0a1/src/uk_open_data/_frames.py +84 -0
  9. uk_open_data-0.2.0a1/src/uk_open_data/_kept.py +63 -0
  10. uk_open_data-0.2.0a1/src/uk_open_data/_mapping.py +219 -0
  11. uk_open_data-0.2.0a1/src/uk_open_data/analyses/__init__.py +98 -0
  12. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_answers.py +182 -0
  13. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_centres.py +494 -0
  14. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_inputs.py +133 -0
  15. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_labels.py +74 -0
  16. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_model.py +433 -0
  17. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_need.py +617 -0
  18. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_privacy.py +180 -0
  19. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_registry.py +289 -0
  20. uk_open_data-0.2.0a1/src/uk_open_data/analyses/_steps.py +747 -0
  21. uk_open_data-0.2.0a1/src/uk_open_data/analyses/access_distance.py +817 -0
  22. uk_open_data-0.2.0a1/src/uk_open_data/analyses/maps.py +1222 -0
  23. uk_open_data-0.2.0a1/src/uk_open_data/analyses/need_reach.py +1188 -0
  24. uk_open_data-0.2.0a1/src/uk_open_data/analyses/provision_gap.py +925 -0
  25. uk_open_data-0.2.0a1/src/uk_open_data/analyses/reach_deprivation.py +1128 -0
  26. uk_open_data-0.2.0a1/src/uk_open_data/analyses/sources.py +82 -0
  27. uk_open_data-0.2.0a1/src/uk_open_data/analyses/who_we_miss.py +1331 -0
  28. uk_open_data-0.2.0a1/src/uk_open_data/cli.py +622 -0
  29. uk_open_data-0.2.0a1/src/uk_open_data/connector/__init__.py +54 -0
  30. uk_open_data-0.2.0a1/src/uk_open_data/connector/__main__.py +6 -0
  31. uk_open_data-0.2.0a1/src/uk_open_data/connector/analyses.py +425 -0
  32. uk_open_data-0.2.0a1/src/uk_open_data/connector/command.py +74 -0
  33. uk_open_data-0.2.0a1/src/uk_open_data/connector/maps.py +336 -0
  34. uk_open_data-0.2.0a1/src/uk_open_data/connector/places.py +644 -0
  35. uk_open_data-0.2.0a1/src/uk_open_data/connector/privacy.py +104 -0
  36. uk_open_data-0.2.0a1/src/uk_open_data/connector/server.py +330 -0
  37. uk_open_data-0.2.0a1/src/uk_open_data/geo/__init__.py +33 -0
  38. uk_open_data-0.2.0a1/src/uk_open_data/geo/_catalog.py +69 -0
  39. uk_open_data-0.2.0a1/src/uk_open_data/geo/_enums.py +116 -0
  40. uk_open_data-0.2.0a1/src/uk_open_data/geo/_ingestion.py +258 -0
  41. uk_open_data-0.2.0a1/src/uk_open_data/geo/api.py +405 -0
  42. uk_open_data-0.2.0a1/src/uk_open_data/geo/data/arcgis_services.csv +655 -0
  43. uk_open_data-0.2.0a1/src/uk_open_data/imd/__init__.py +17 -0
  44. uk_open_data-0.2.0a1/src/uk_open_data/imd/api.py +621 -0
  45. uk_open_data-0.2.0a1/src/uk_open_data/ons/__init__.py +12 -0
  46. uk_open_data-0.2.0a1/src/uk_open_data/ons/_catalog.py +42 -0
  47. uk_open_data-0.2.0a1/src/uk_open_data/ons/_ingestion.py +100 -0
  48. uk_open_data-0.2.0a1/src/uk_open_data/ons/api.py +199 -0
  49. uk_open_data-0.2.0a1/src/uk_open_data/ons/data/nomis_tables.csv +1616 -0
  50. uk_open_data-0.2.0a1/src/uk_open_data/postcodes/__init__.py +44 -0
  51. uk_open_data-0.2.0a1/src/uk_open_data/postcodes/api.py +318 -0
  52. uk_open_data-0.2.0a1/src/uk_open_data/postcodes/offline.py +488 -0
  53. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/PKG-INFO +188 -0
  54. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/SOURCES.txt +80 -0
  55. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/dependency_links.txt +1 -0
  56. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/entry_points.txt +3 -0
  57. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/requires.txt +7 -0
  58. uk_open_data-0.2.0a1/src/uk_open_data.egg-info/top_level.txt +1 -0
  59. uk_open_data-0.2.0a1/tests/test_analyses.py +1135 -0
  60. uk_open_data-0.2.0a1/tests/test_analysis_access_distance.py +1047 -0
  61. uk_open_data-0.2.0a1/tests/test_analysis_maps.py +734 -0
  62. uk_open_data-0.2.0a1/tests/test_analysis_need_reach.py +1468 -0
  63. uk_open_data-0.2.0a1/tests/test_analysis_provision_gap.py +743 -0
  64. uk_open_data-0.2.0a1/tests/test_analysis_who_we_miss.py +1154 -0
  65. uk_open_data-0.2.0a1/tests/test_cli.py +530 -0
  66. uk_open_data-0.2.0a1/tests/test_connector_analyses.py +829 -0
  67. uk_open_data-0.2.0a1/tests/test_connector_kept_index.py +81 -0
  68. uk_open_data-0.2.0a1/tests/test_connector_maps.py +377 -0
  69. uk_open_data-0.2.0a1/tests/test_connector_places.py +349 -0
  70. uk_open_data-0.2.0a1/tests/test_connector_privacy.py +365 -0
  71. uk_open_data-0.2.0a1/tests/test_connector_server.py +414 -0
  72. uk_open_data-0.2.0a1/tests/test_geo_api.py +542 -0
  73. uk_open_data-0.2.0a1/tests/test_geo_enums.py +47 -0
  74. uk_open_data-0.2.0a1/tests/test_geo_ingestion.py +193 -0
  75. uk_open_data-0.2.0a1/tests/test_imd_api.py +511 -0
  76. uk_open_data-0.2.0a1/tests/test_mapping.py +210 -0
  77. uk_open_data-0.2.0a1/tests/test_old_name.py +160 -0
  78. uk_open_data-0.2.0a1/tests/test_old_name_package.py +30 -0
  79. uk_open_data-0.2.0a1/tests/test_ons_api.py +191 -0
  80. uk_open_data-0.2.0a1/tests/test_ons_ingestion.py +111 -0
  81. uk_open_data-0.2.0a1/tests/test_postcodes_api.py +211 -0
  82. uk_open_data-0.2.0a1/tests/test_postcodes_offline.py +376 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,32 @@
1
+ KindTech UK open data package
2
+ Copyright 2026 KindTech UK
3
+
4
+ This product includes software developed by KindTech UK and its contributors
5
+ (https://github.com/KindTechUK).
6
+
7
+ It is licensed under the Apache License, Version 2.0. See the LICENSE file.
8
+
9
+ Version 0.1.0 was published under the MIT License. The code it contained is
10
+ still in this package, so that licence's notice is kept here:
11
+
12
+ MIT License
13
+
14
+ Copyright (c) 2026 KindTech UK
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: uk-open-data
3
+ Version: 0.2.0a1
4
+ Summary: UK open data in Python for civil society, from charities and community groups to researchers and students
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/KindTechUK/uk-open-data
7
+ Project-URL: Documentation, https://kindtechuk.github.io/uk-open-data/
8
+ Project-URL: llms.txt, https://kindtechuk.github.io/uk-open-data/llms.txt
9
+ Project-URL: Repository, https://github.com/KindTechUK/uk-open-data
10
+ Project-URL: Issues, https://github.com/KindTechUK/uk-open-data/issues
11
+ Keywords: uk,open-data,ons,nomis,census,postcodes,imd,deprivation,geospatial,charity,civil-society,research
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Natural Language :: English
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: GIS
23
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ Requires-Dist: requests>=2.28
29
+ Requires-Dist: narwhals>=2.18.0
30
+ Requires-Dist: python-calamine>=0.2
31
+ Provides-Extra: connector
32
+ Requires-Dist: mcp<3,>=2.3; extra == "connector"
33
+ Requires-Dist: pandas>=2.0.0; extra == "connector"
34
+ Dynamic: license-file
35
+
36
+ # uk-open-data
37
+
38
+ UK open data in Python for civil society, from charities and community groups
39
+ to researchers and students. Load public data from official sources, join it
40
+ to your own, and get figures you can check. The first datasets are geographic
41
+ boundaries, official statistics, postcodes and deprivation indices, with more
42
+ on the way.
43
+
44
+ Made by [KindTech UK](https://github.com/KindTechUK). Up to version 0.1 the
45
+ package was called `kindtech`.
46
+
47
+ ## What is in it
48
+
49
+ - **Data modules.** `uk_open_data.geo` loads boundaries from the ONS
50
+ Geoportal, `uk_open_data.ons` loads statistics from the Nomis API,
51
+ `uk_open_data.postcodes` turns postcodes into geography codes, and
52
+ `uk_open_data.imd` loads the deprivation indices. Bring your own DataFrame
53
+ backend, pandas or polars.
54
+ - **[Analyses](https://kindtechuk.github.io/uk-open-data/api/analyses/).** Each
55
+ analysis answers one question a charity asks of its own data, such as "Are we
56
+ reaching people in the most deprived neighbourhoods?". It returns totals,
57
+ the working, the sources and what a person must check. Nothing in a result
58
+ describes one person.
59
+ - **[A command line](https://kindtechuk.github.io/uk-open-data/api/cli/).**
60
+ `uk-open-data analysis run` runs an analysis on a file without writing any
61
+ Python.
62
+ - **[A connector for chat assistants](https://kindtechuk.github.io/uk-open-data/api/connector/).**
63
+ The same analyses and data as tools for an assistant such as Claude or
64
+ ChatGPT. The assistant sees totals, never rows.
65
+
66
+ These analyses follow work first done by
67
+ [DataKind UK](https://www.datakind.org.uk/) volunteers with charities.
68
+
69
+ ## Installation
70
+
71
+ Install [uk-open-data from PyPI](https://pypi.org/project/uk-open-data/):
72
+
73
+ ```bash
74
+ uv add uk-open-data
75
+ ```
76
+
77
+ The `uk-open-data` package includes `uk_open_data.geo`, `uk_open_data.ons`,
78
+ `uk_open_data.postcodes`, and `uk_open_data.imd`. See the
79
+ [package FAQ](https://kindtechuk.github.io/uk-open-data/faq/) for how these
80
+ subpackages are installed and released together.
81
+
82
+ ## Quick start
83
+
84
+ ```python
85
+ import pandas as pd # or polars
86
+
87
+ from uk_open_data import (
88
+ geodata_to_properties,
89
+ load_geodata,
90
+ load_ons,
91
+ postcodes_to_geography,
92
+ )
93
+
94
+ # Local authority boundaries from the ONS Geoportal
95
+ geojson = load_geodata(geography_type="LAD", year="2025", boundary_type="BUC")
96
+ areas = pd.DataFrame(geodata_to_properties(geojson, "LAD", 2025))
97
+
98
+ # Population of each local authority from Nomis: all persons, all ages
99
+ population = load_ons(
100
+ "population",
101
+ geography_type="LAD",
102
+ time="latest",
103
+ measures=20100,
104
+ gender=0,
105
+ c_age=200,
106
+ select=["geography_code", "obs_value"],
107
+ )
108
+
109
+ # Every dataset has a geography_code column, so they join directly
110
+ areas = areas.merge(population, on="geography_code")
111
+
112
+ # Your own postcodes, placed in the same local authorities
113
+ located = postcodes_to_geography(["SE13 7HX", "SE6 4RU"], geography_type="LAD")
114
+ located.merge(population, on="geography_code")
115
+ # postcode geography_code geography_name obs_value
116
+ # 0 SE13 7HX E09000023 Lewisham 301037
117
+ # 1 SE6 4RU E09000023 Lewisham 301037
118
+ ```
119
+
120
+ The [user guide](https://kindtechuk.github.io/uk-open-data/api/) covers each
121
+ module.
122
+
123
+ ## Examples
124
+
125
+ Interactive notebooks you can run in the browser:
126
+
127
+ | Notebook | Description |
128
+ |----------|-------------|
129
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/ons_statistics.py) | Browse and load ONS datasets from the NOMIS API |
130
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/geo_boundaries.py) | Explore UK geographic boundaries |
131
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/geo_plus_ons.py) | Join boundaries with statistics |
132
+
133
+ ### Case studies
134
+
135
+ End-to-end reproductions of [DataKind UK](https://www.datakind.org.uk/) charity
136
+ projects, each chaining several connectors on `geography_code`:
137
+
138
+ | Notebook | Case study |
139
+ |----------|------------|
140
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/smart_works_unemployment.py) | **Smart Works** — women's unemployment vs service reach (Census 2021 + LAD boundaries) |
141
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/cal_vulnerable_client.py) | **Citizens Advice Lewisham** — deprivation vs service usage (postcodes + IMD + LSOA boundaries) |
142
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/sobus_bame_referrals.py) | **Sobus** — BAME mental-health referrals in Hammersmith & Fulham (outcodes + Census ethnicity) |
143
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/starlight_play_provision.py) | **Starlight** — hospital play provision vs need across ICBs |
144
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/material_focus_recycling.py) | **Material Focus** — travel time to the nearest recycling point (LAD boundaries + population) |
145
+
146
+ See the [case studies](https://kindtechuk.github.io/uk-open-data/case-studies/) in
147
+ the docs for the full write-ups and figures.
148
+
149
+ ## For students and researchers
150
+
151
+ The same loaders work for coursework, a dissertation or a research project.
152
+ Each one fetches from an official source, and
153
+ [Data sources](https://kindtechuk.github.io/uk-open-data/api/data-sources/)
154
+ explains the APIs behind them. The notebooks above run in the browser with
155
+ nothing to install.
156
+
157
+ Students and researchers are welcome to contribute: a new data source, a worked
158
+ analysis, or a fix to the docs. Read the
159
+ [contributing guide](https://github.com/KindTechUK/.github/blob/main/CONTRIBUTING.md)
160
+ and [DEVELOPERS.md](https://github.com/KindTechUK/uk-open-data/blob/main/DEVELOPERS.md),
161
+ then open an [issue](https://github.com/KindTechUK/uk-open-data/issues) to say
162
+ what you would like to work on.
163
+
164
+ ## Use it from an AI assistant
165
+
166
+ In Claude Code, install the plugin:
167
+
168
+ ```text
169
+ /plugin marketplace add KindTechUK/plugins
170
+ /plugin install uk-open-data@kindtech
171
+ ```
172
+
173
+ For other assistants, the
174
+ [connector](https://kindtechuk.github.io/uk-open-data/api/connector/) offers the
175
+ analyses and data over the Model Context Protocol. Coding agents can read the
176
+ docs as Markdown: [llms.txt](https://kindtechuk.github.io/uk-open-data/llms.txt)
177
+ lists every page, and
178
+ [llms-full.txt](https://kindtechuk.github.io/uk-open-data/llms-full.txt) holds
179
+ them all in one file.
180
+
181
+ ## Development
182
+
183
+ See [DEVELOPERS.md](DEVELOPERS.md) for development setup and workflow instructions.
184
+
185
+ ## Licence
186
+
187
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). Version 0.1.0 was
188
+ published under the MIT License; its notice is kept in NOTICE.
@@ -0,0 +1,153 @@
1
+ # uk-open-data
2
+
3
+ UK open data in Python for civil society, from charities and community groups
4
+ to researchers and students. Load public data from official sources, join it
5
+ to your own, and get figures you can check. The first datasets are geographic
6
+ boundaries, official statistics, postcodes and deprivation indices, with more
7
+ on the way.
8
+
9
+ Made by [KindTech UK](https://github.com/KindTechUK). Up to version 0.1 the
10
+ package was called `kindtech`.
11
+
12
+ ## What is in it
13
+
14
+ - **Data modules.** `uk_open_data.geo` loads boundaries from the ONS
15
+ Geoportal, `uk_open_data.ons` loads statistics from the Nomis API,
16
+ `uk_open_data.postcodes` turns postcodes into geography codes, and
17
+ `uk_open_data.imd` loads the deprivation indices. Bring your own DataFrame
18
+ backend, pandas or polars.
19
+ - **[Analyses](https://kindtechuk.github.io/uk-open-data/api/analyses/).** Each
20
+ analysis answers one question a charity asks of its own data, such as "Are we
21
+ reaching people in the most deprived neighbourhoods?". It returns totals,
22
+ the working, the sources and what a person must check. Nothing in a result
23
+ describes one person.
24
+ - **[A command line](https://kindtechuk.github.io/uk-open-data/api/cli/).**
25
+ `uk-open-data analysis run` runs an analysis on a file without writing any
26
+ Python.
27
+ - **[A connector for chat assistants](https://kindtechuk.github.io/uk-open-data/api/connector/).**
28
+ The same analyses and data as tools for an assistant such as Claude or
29
+ ChatGPT. The assistant sees totals, never rows.
30
+
31
+ These analyses follow work first done by
32
+ [DataKind UK](https://www.datakind.org.uk/) volunteers with charities.
33
+
34
+ ## Installation
35
+
36
+ Install [uk-open-data from PyPI](https://pypi.org/project/uk-open-data/):
37
+
38
+ ```bash
39
+ uv add uk-open-data
40
+ ```
41
+
42
+ The `uk-open-data` package includes `uk_open_data.geo`, `uk_open_data.ons`,
43
+ `uk_open_data.postcodes`, and `uk_open_data.imd`. See the
44
+ [package FAQ](https://kindtechuk.github.io/uk-open-data/faq/) for how these
45
+ subpackages are installed and released together.
46
+
47
+ ## Quick start
48
+
49
+ ```python
50
+ import pandas as pd # or polars
51
+
52
+ from uk_open_data import (
53
+ geodata_to_properties,
54
+ load_geodata,
55
+ load_ons,
56
+ postcodes_to_geography,
57
+ )
58
+
59
+ # Local authority boundaries from the ONS Geoportal
60
+ geojson = load_geodata(geography_type="LAD", year="2025", boundary_type="BUC")
61
+ areas = pd.DataFrame(geodata_to_properties(geojson, "LAD", 2025))
62
+
63
+ # Population of each local authority from Nomis: all persons, all ages
64
+ population = load_ons(
65
+ "population",
66
+ geography_type="LAD",
67
+ time="latest",
68
+ measures=20100,
69
+ gender=0,
70
+ c_age=200,
71
+ select=["geography_code", "obs_value"],
72
+ )
73
+
74
+ # Every dataset has a geography_code column, so they join directly
75
+ areas = areas.merge(population, on="geography_code")
76
+
77
+ # Your own postcodes, placed in the same local authorities
78
+ located = postcodes_to_geography(["SE13 7HX", "SE6 4RU"], geography_type="LAD")
79
+ located.merge(population, on="geography_code")
80
+ # postcode geography_code geography_name obs_value
81
+ # 0 SE13 7HX E09000023 Lewisham 301037
82
+ # 1 SE6 4RU E09000023 Lewisham 301037
83
+ ```
84
+
85
+ The [user guide](https://kindtechuk.github.io/uk-open-data/api/) covers each
86
+ module.
87
+
88
+ ## Examples
89
+
90
+ Interactive notebooks you can run in the browser:
91
+
92
+ | Notebook | Description |
93
+ |----------|-------------|
94
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/ons_statistics.py) | Browse and load ONS datasets from the NOMIS API |
95
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/geo_boundaries.py) | Explore UK geographic boundaries |
96
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/geo_plus_ons.py) | Join boundaries with statistics |
97
+
98
+ ### Case studies
99
+
100
+ End-to-end reproductions of [DataKind UK](https://www.datakind.org.uk/) charity
101
+ projects, each chaining several connectors on `geography_code`:
102
+
103
+ | Notebook | Case study |
104
+ |----------|------------|
105
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/smart_works_unemployment.py) | **Smart Works** — women's unemployment vs service reach (Census 2021 + LAD boundaries) |
106
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/cal_vulnerable_client.py) | **Citizens Advice Lewisham** — deprivation vs service usage (postcodes + IMD + LSOA boundaries) |
107
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/sobus_bame_referrals.py) | **Sobus** — BAME mental-health referrals in Hammersmith & Fulham (outcodes + Census ethnicity) |
108
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/starlight_play_provision.py) | **Starlight** — hospital play provision vs need across ICBs |
109
+ | [![Open in molab](https://marimo.io/molab-shield.svg)](https://molab.marimo.io/github/KindTechUK/uk-open-data/blob/main/examples/material_focus_recycling.py) | **Material Focus** — travel time to the nearest recycling point (LAD boundaries + population) |
110
+
111
+ See the [case studies](https://kindtechuk.github.io/uk-open-data/case-studies/) in
112
+ the docs for the full write-ups and figures.
113
+
114
+ ## For students and researchers
115
+
116
+ The same loaders work for coursework, a dissertation or a research project.
117
+ Each one fetches from an official source, and
118
+ [Data sources](https://kindtechuk.github.io/uk-open-data/api/data-sources/)
119
+ explains the APIs behind them. The notebooks above run in the browser with
120
+ nothing to install.
121
+
122
+ Students and researchers are welcome to contribute: a new data source, a worked
123
+ analysis, or a fix to the docs. Read the
124
+ [contributing guide](https://github.com/KindTechUK/.github/blob/main/CONTRIBUTING.md)
125
+ and [DEVELOPERS.md](https://github.com/KindTechUK/uk-open-data/blob/main/DEVELOPERS.md),
126
+ then open an [issue](https://github.com/KindTechUK/uk-open-data/issues) to say
127
+ what you would like to work on.
128
+
129
+ ## Use it from an AI assistant
130
+
131
+ In Claude Code, install the plugin:
132
+
133
+ ```text
134
+ /plugin marketplace add KindTechUK/plugins
135
+ /plugin install uk-open-data@kindtech
136
+ ```
137
+
138
+ For other assistants, the
139
+ [connector](https://kindtechuk.github.io/uk-open-data/api/connector/) offers the
140
+ analyses and data over the Model Context Protocol. Coding agents can read the
141
+ docs as Markdown: [llms.txt](https://kindtechuk.github.io/uk-open-data/llms.txt)
142
+ lists every page, and
143
+ [llms-full.txt](https://kindtechuk.github.io/uk-open-data/llms-full.txt) holds
144
+ them all in one file.
145
+
146
+ ## Development
147
+
148
+ See [DEVELOPERS.md](DEVELOPERS.md) for development setup and workflow instructions.
149
+
150
+ ## Licence
151
+
152
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). Version 0.1.0 was
153
+ published under the MIT License; its notice is kept in NOTICE.