Skip to main content

Pakkenellik

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 S3
  • config: common paths and URLs for Bord4 projects
  • dataframe: cleaning columns, date/time helpers and number formatting
  • datawrapper: low-level Datawrapper client helpers
  • google: reading from and writing to Google Sheets
  • integration: Schibsted MM and Datawrapper integration helpers
  • regions: Norwegian municipality and county data, including historical changes
  • ssb: population data, rates and ranking helpers
  • vegvesen: routes and road data from the Norwegian Public Roads Administration
  • viz: 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.4

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

Source distribution (sdist)

Source distribution for pakkenellik 0.2.4
File Size Uploaded Provenance Actions
pakkenellik-0.2.4.tar.gz 435.9 kB Without provenance Details for pakkenellik-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pakkenellik 0.2.4
File Interpreter ABI Platform Actions
pakkenellik-0.2.4-py3-none-any.whl Python 3 none any Details for pakkenellik-0.2.4-py3-none-any.whl

Total release size: 467.5 kB

Release files / pakkenellik-0.2.4.tar.gz

Download URL pakkenellik-0.2.4.tar.gz
Size 435.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b354a35a41dd3a4e048d623d80a37cc01fed994852e22cdf619d63d0ccd84bd4
BLAKE2b-256 checksum
How to use checksums
9526c65f843fd46c90c87dcde1141675a33b63e19578903e52d6333983d8ce05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Release files / pakkenellik-0.2.4-py3-none-any.whl

Download URL pakkenellik-0.2.4-py3-none-any.whl
Size 31.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8744f0f4f8286718ec2b86eb5a2c19ccb5fc12f5c2ec7d6f5f5d8d0b687e5689
BLAKE2b-256 checksum
How to use checksums
6b1137d34f0e4fa86d2f8a3a172d9ebe26cde938a2ca5d13b56ec70792a4d808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Security for pakkenellik 0.2.4

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.

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