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.10 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.3

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.3
File Size Uploaded Provenance Actions
pakkenellik-0.2.3.tar.gz 472.9 kB Without provenance Details for pakkenellik-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 506.2 kB

Release files / pakkenellik-0.2.3.tar.gz

Download URL pakkenellik-0.2.3.tar.gz
Size 472.9 kB
Tags Source
SHA-256 checksum
How to use checksums
44657685f623618f7cd205e922c62db4ff24934efadea33babae9131847c44e1
BLAKE2b-256 checksum
How to use checksums
a10cce3afd654815e286e2191d3497b9885d958a9896beef04c9b8928d593e93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

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

Download URL pakkenellik-0.2.3-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
324fd6145298e93620b0a388b8225113cca169be4b0a32c40b9ea5dea94e14f3
BLAKE2b-256 checksum
How to use checksums
fb1561500016b52c681b5b28e8f5865f9ebc4723453374f904b02c67be174a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Security for pakkenellik 0.2.3

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