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.1

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.1
File Size Uploaded
ng_postcode_polars-0.1.1.tar.gz 75.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ng-postcode-polars 0.1.1
File
ng_postcode_polars-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
ng_postcode_polars-0.1.1-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.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
ng_postcode_polars-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
ng_postcode_polars-0.1.1-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.1.tar.gz

Download URL ng_postcode_polars-0.1.1.tar.gz
Size 75.3 kB
Tags Source
SHA-256 checksum
How to use checksums
37a3e8b5e410c7071226654e34fe42fa71dda8f90cd9640cb3e4ff1589df89b9
BLAKE2b-256 checksum
How to use checksums
4a716fc919d6fd2e9f1c2bbcc680d19c602535412f70f5d9ee905ab19f17bb27
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 16, 2026.

Transparency log

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

Download URL ng_postcode_polars-0.1.1-cp310-abi3-win_amd64.whl
Size 4.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f6cd7de0fd37ce263abf1b403504ea8310de179142066f97c9ecd7ef9cd82795
BLAKE2b-256 checksum
How to use checksums
0e6f838c01e7c6c748cb361eac59aba78b3e1e12fd20c277d229b8ccfcd6fa8a
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 16, 2026.

Transparency log

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

Download URL ng_postcode_polars-0.1.1-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
db1b71505cf9c2b72a27c4446b379725fba86eab14aa132c64f4cee0cb3db87f
BLAKE2b-256 checksum
How to use checksums
a0c2fc3f7085c2a4a6efa70c3f607ae31520806ac56f49384af52d133f1638cc
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 16, 2026.

Transparency log

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

Download URL ng_postcode_polars-0.1.1-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
1a5ae57c7efd8aaeb823bcf65965720a203f204f87f05c3075d79682d1b1a85a
BLAKE2b-256 checksum
How to use checksums
ff388b5001f90f6969eca7d0e55162ce9d72615cd82fc0a33bac0a073b315ddc
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 16, 2026.

Transparency log

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

Download URL ng_postcode_polars-0.1.1-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
7e9e646889135a9754097b7addd6acd9e30bc50acceb42761bad7736933515c4
BLAKE2b-256 checksum
How to use checksums
a58b87026345930e2e9332806567d13ce7bc97b06e428ba9fed3d655d8eac5f5
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 16, 2026.

Transparency log

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

Download URL ng_postcode_polars-0.1.1-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
5fe3c73df545c0093111ea6778c9e3f71132c29434065c0d35b8bbbcf385db30
BLAKE2b-256 checksum
How to use checksums
8ecb586352144175f47d272f2ce0b7c74ae583227636d2dc358acea8c8983f01
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 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

6 release files

0.1.0

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