Pakkenellik is a collection of shared Python utilities for Bord4's data-analysis projects. It includes helpers for dataframes, project paths, publishing, integrations, Norwegian regions and Statistics Norway (SSB).
The package is used by bord4-analysis-templates.
Requirements
- Python 3.11 or later
- pandas 3.0 or later
Installation
Install the core package with pip:
pip install pakkenellik
Or add it to a project managed by uv:
uv add pakkenellik
Optional dependencies are grouped by feature:
uv add "pakkenellik[s3]" # Amazon S3
uv add "pakkenellik[gspread]" # Google Sheets
uv add "pakkenellik[nvdb]" # Norwegian Public Roads Administration
uv add "pakkenellik[gis]" # Geospatial dataframes
uv add "pakkenellik[viz]" # Matplotlib visualizations
uv add "pakkenellik[datawrapper]" # Datawrapper
uv add "pakkenellik[ssb]" # SSB helpers (no additional dependencies)
Usage
Clean dataframe column names:
import pandas as pd
from pakkenellik.dataframe.clean_column_headers import clean_column_headers
df = pd.DataFrame({"Første kolonne": [1]})
df = clean_column_headers(df)
# df.columns: ["forste_kolonne"]
Format numbers with Norwegian separators:
from pakkenellik.dataframe.numbers import format_number
formatted = format_number(1234567.89)
# "1.234.567,89"
Use common project paths:
from pakkenellik.config import Config
config = Config("/path/to/project")
source_file = config.get_source_file("data.csv")
# "/path/to/project/data/source/data.csv"
Inspect municipality changes and require geographically safe mappings when joining historical data to current municipalities:
from pakkenellik.regions import (
get_current_municipality_ids,
get_region_transitions,
)
get_region_transitions("1439")[["from_id", "to_id", "mapping_quality"]]
# Vågsøy maps partly to Kinn and partly to Stad; quality is "split_merge".
get_current_municipality_ids("1439", safe_only=True)
# [] — whole-municipality statistics cannot be mapped safely.
Features
aws: publishing files and data to Amazon S3config: common paths and URLs for Bord4 projectsdataframe: cleaning columns, date/time helpers and number formattingdatawrapper: low-level Datawrapper client helpersgoogle: reading from and writing to Google Sheetsintegration: Schibsted MM and Datawrapper integration helpersregions: Norwegian municipality and county data, including historical changesssb: population data, rates and ranking helpersvegvesen: routes and road data from the Norwegian Public Roads Administrationviz: shared Matplotlib styling and plotting helpers
Local development
Install uv, clone the repository and install all development and optional dependencies:
git clone https://github.com/BergensTidende/pakkenellik.git
cd pakkenellik
make sync
The Makefile provides these common commands:
| Command | Description |
|---|---|
make format |
Format and sort imports with Ruff |
make lint |
Check formatting, linting and types with Ruff and mypy |
make test |
Run the pytest test suite |
make check |
Run all linting and tests |
Contributing
Create a branch from main, make your changes and verify them before opening a
pull request:
git switch -c name-of-branch
make check
git push -u origin name-of-branch
Use present-tense commit messages that describe what the commit does. If you do
not have write access to the repository, create a personal fork and open the pull
request from your fork against the repository's main branch.
License
Pakkenellik is distributed under the MIT License.
Contact
Bord4 — bord4@bt.no
Metadata
Release files for pakkenellik 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pakkenellik-0.2.5.tar.gz | 443.5 kB | Without provenance | Details for pakkenellik-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pakkenellik-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for pakkenellik-0.2.5-py3-none-any.whl |
Total release size: 475.1 kB
Release files / pakkenellik-0.2.5.tar.gz
| Download URL | pakkenellik-0.2.5.tar.gz |
|---|---|
| Size | 443.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85aad39df68a501be58671605f8b4dfa87f0d029e0117f01675ade4446421d20
|
|
BLAKE2b-256 checksum How to use checksums |
4d29d2ce947471b5ac5058844f1b4667aadd744f4313b213243900b22898c024
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pakkenellik-0.2.5-py3-none-any.whl
| Download URL | pakkenellik-0.2.5-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bdba961fc887f638aa2815839b57c39963f6dba3716194f9f9cdbfdce2a6da3
|
|
BLAKE2b-256 checksum How to use checksums |
ef1811e149e5a6135e0896b7fa4a0a681e9c1f711456ea7b6fe987a98b38e6c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for pakkenellik 0.2.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.