Skip to main content

ng-postcode-polars

Polars expressions for Nigeria's NIPOST digital postcode (NDAPS), the 11-character building code such as EK-01-A03-FK-01. They parse, format, and cut codes down to a state, LGA, district, or area, so that a DataFrame can be grouped by place with no map.

The work is done in Rust by the same core as the ng-postcode libraries, in one pass over the column. On a million rows that is about 40 times faster than calling a Python function for each row.

pip install ng-postcode-polars

Usage

Importing the package adds an ng namespace to every expression.

import polars as pl
import ng_postcode_polars  # noqa: F401

frame = pl.DataFrame({"postcode": ["ek 01 a03 fk 01", "EK-01-A03-ZZ-14", "la11w06tc10", "100001"]})

print(
    frame.with_columns(
        code=pl.col("postcode").ng.parse(),
        ok=pl.col("postcode").ng.is_valid(),
    )
)
# postcode         code         ok
# ek 01 a03 fk 01  EK01A03FK01  true
# EK-01-A03-ZZ-14  EK01A03ZZ14  true
# la11w06tc10      LA11W06TC10  true
# 100001           null         false

A value that is not a well-formed code becomes null, so it can be counted and followed up.

Group by place

by_district = frame.group_by(
    pl.col("postcode").ng.truncate("district").ng.format().alias("district")
).len()
# EK-01-A03  2
# LA-11-W06  1
# null       1

Expressions

Expression Returns
.ng.parse() The compact code, EK01A03FK01, or null
.ng.is_valid() Whether the value is a well-formed code
.ng.format() The hyphenated form of a code or a prefix
.ng.truncate(segment) The compact prefix through state, lga, district, area, or unit
.ng.parse_prefix() The compact prefix, such as EK01A03, or null

A type checker cannot see a namespace that is registered at import time. For checked code, call the class directly: Postcodes(pl.col("postcode")).parse().

The expressions follow the shared cases in spec/vectors.json, as every ng-postcode library does. A well-formed code is not necessarily assigned to a building, and only the NIPOST API can confirm that.

License

MIT

Metadata

Release files for ng-postcode-polars 0.1.0

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

Source distribution (sdist)

Source distribution for ng-postcode-polars 0.1.0
File Size Uploaded
ng_postcode_polars-0.1.0.tar.gz 74.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ng-postcode-polars 0.1.0
File
ng_postcode_polars-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
ng_postcode_polars-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
ng_postcode_polars-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 23.0 MB

Release files / ng_postcode_polars-0.1.0.tar.gz

Download URL ng_postcode_polars-0.1.0.tar.gz
Size 74.8 kB
Tags Source
SHA-256 checksum
How to use checksums
55b512fc0483d88342f0b0a4c0cc073f92bce7f8fde3711786cf58eb50bc3f31
BLAKE2b-256 checksum
How to use checksums
d20ef711f9e78c2481b8b806a7a92378fe21706d67aac0b654a9d42f12f71787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / ng_postcode_polars-0.1.0-cp310-abi3-win_amd64.whl

Download URL ng_postcode_polars-0.1.0-cp310-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b1912a81d098347e69e9ae1a0e29f595f89b71aa3ffc61c29debb57a99659f8b
BLAKE2b-256 checksum
How to use checksums
87f280428a5db386f5ed601498af819adfcce64d07d7ade71bb6072af038a778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
169d9c0753f017b6b1f2e362a06c6c1d569db8cb46a02adfb0e5cb9a747d6bd3
BLAKE2b-256 checksum
How to use checksums
9eb1c377ce301dda2a3233755ec2e5bc04f68f2086846b6bab833068e4869c79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL ng_postcode_polars-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.0 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0de9141298e0ee5601794b8b25ab2ca993e06eece91a1b3050571e25f009ba41
BLAKE2b-256 checksum
How to use checksums
8761a991208700708e6d2b0b6fe9bf006cb85e3cc7b0344ac0a002aa3040c174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / ng_postcode_polars-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL ng_postcode_polars-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 4.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d430a675cc790bf80f51db33f0039b5538d20ec748ec1e2a89fed6263f74f94
BLAKE2b-256 checksum
How to use checksums
3d8337900d12c71b8152100acfb6de02ba6ce4eb8d6de166620edb57da110145
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / ng_postcode_polars-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ng_postcode_polars-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 4.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
dc2331918ba68e4800038a4d52167a5de022c06e28e5fd7b160c2278bcc82487
BLAKE2b-256 checksum
How to use checksums
c3e545cee0407455a3ad2ce8122bc1303eeae2120d672507fa4354676dbe16e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.1

6 release files

This release

0.1.0 This release

6 release files

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