Skip to main content

Toolkit for cleaning, validating, extracting and contextualising GB address data with PySpark.

Project description

Address Toolkit

Python License

Introduction

The address toolkit package supports the cleaning and processing of address data registered as a pyspark.sql.DataFrame. The package includes functions for cleaning, validating, extracting and contextualising addresses and address components. Additionally, workflows have been created as an 'out-of-the-box' application combining the functions across cleaning, validating and extracting.

To install the package, run:

pip install address-toolkit

To register a spark dataframe from a CSV, the following code can be run.

from pyspark.sql import SparkSession


spark = SparkSession.builder.master("local").appName("test").getOrCreate()
df = spark.read.csv("test.csv")

A recommended first step in using this package is to apply the clean_punctuation function from address_toolkit.cleaning.

from address_toolkit.cleaning import clean_punctuation

df = clean_punctuation(df, 'address_column', create_flag = True, overwrite = True)

Main Package Contents:

Folder Name Description Includes
cleaning Contains functions to clean addresses clean_punctuation, denoise_addresses, deduplicate_addresses, deduplicate_postcodes, rectify_postcodes, standardise_street_types, prettify_addresses
validating Contains functions to validate addresses validate_from_list, validate_from_regex, validate_postcodes
extracting Contains functions to extract address components extract_from_list, extract_from_regex, extract_postcodes
contextualising Contains functions to contextualise addresses contextualise_from_lookup
workflows Contains functions to streamline processing clean_addresses, validate_addresses, extract_address_components

Supplementary Package Contents (Resources):

Resource Includes
UK Postcode Regex postcode_regex
Unit Address Level Regex flat_regex, room_regex, unit_regex, block_regex, apartment_regex, floor_regex
Noise Regex consecutive_letters_regex
Miscellaneous Regex misc_numbers_regex, standalone_numbers_regex, txt_before_numbers_regex, end_address_numbers_regex, start_address_numbers_regex, end_address_identifier_regex
Address Component Lists town_list, city_list, village_list, hamlet_list, suburb_list, bay_list, place_list, district_list, county_list, allowed_country_list, disallowed_country_list
Keyword Component Lists contextual_keywords, misc_keywords_list, misc_special_keywords
Address Component Lookups town_lookup, village_lookup, bay_lookup, hamlet_lookup, suburb_lookup

Note: For unit address level RegEx patterns, alternatives i.e. flat_regex_alternative are available which are less 'strict' in their matching.

Address Component lists and lookups have been created from Ordnance Survey Open Names. Contains OS data © Crown copyright and database right 2026. Licensed under the Open Government License v3.0. This dataset is updated quarterly in January, April, July and October.

Postcode processing is based upon the Annex C - Valid post code format specification.

Example Usage

See tutorial.ipynb for full use of all the functions within cleaning, validating, extracting, contextualising and workflows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

address_toolkit-1.2.1.tar.gz (995.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

address_toolkit-1.2.1-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file address_toolkit-1.2.1.tar.gz.

File metadata

  • Download URL: address_toolkit-1.2.1.tar.gz
  • Upload date:
  • Size: 995.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for address_toolkit-1.2.1.tar.gz
Algorithm Hash digest
SHA256 3e6039d233f9fe315577585c1f0929880fa28e73197fb87b7668c88383b04575
MD5 2c7316f621437e843d988d2a7e8cc730
BLAKE2b-256 6eb6bba4e592a34bc04b7efd8c04faf65c6c95ea8c4d4ba897da9381ff3af6f6

See more details on using hashes here.

File details

Details for the file address_toolkit-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for address_toolkit-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a71049abbe898471832f9aec5a15c9bad84c704401aa3642168152c98ae670
MD5 5b1672e94dc1e5b389640e01f85776c4
BLAKE2b-256 45d3fd095ecf247ad03d61afb28d78e00c939f7f77c4291476726ae1494f8586

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page