Befolkning Fagfunksjoner
Project description
Befolkning Fagfunksjoner
Collection of python functions used in statistics production in the Division for Population Statistics at Statistics Norway.
Features
- TODO
Requirements
- TODO
Installation
poetry add ssb-befolkning-fagfunksjoner
Usage
EventParams
EventParams contains logic for:
- Prompting and validating parameters for event periods
- Creating period labels
- Computing calendar window for the chosen period
- Exposing event parameters for parameterising SQL queries
Supported period types are:
yearhalfyear(1-2)quarter(1-4)month(1-12)week(ISO week, 1-53)
The class can be constructed with explicit arguments in code:
from ssb_befolkning_fagfunksjoner import EventParams
# Example: March 2024, with default wait period (1 month, 0 days)
params = EventParams(
year=2024,
period_type="month",
period_number=3,
specify_wait_period=False, # default; can be omitted
)
If input arguments are omitted, the user will be prompted:
year: prompts for an integer between 1900 and current yearperiod_type: prompts for a valid period type- Accepts both full names (
"quarter","month", etc.) and single-letter abbreviations ("q","m", etc.)
- Accepts both full names (
period_number: prompted only when needed, with appropriate range checks (e.g. 1-12 for months)
from ssb_befolkning_fagfunksjoner import EventParams
# Will ask the user for missing values in the terminal
params = EventParams()
Once the class is constructed, get the period label as follows:
# Example: March 2024, with default wait period
period_label = params.period_label
# "p2024-03"
Get the start and end dates of the period using the window property:
# Example: March 2024, with default wait period
start_date, end_date = params.window
# datetime.date(2024, 3, 1), datetime.date(2024, 3, 31)
Get a dict used for parameterising SQL-queries:
sql_param = params.to_query_params()
# {
# "start_date": datetime.date(2024, 3, 1),
# "end_date": datetime.date(2024, 3, 31),
# "etterslep_start": datetime.date(2024, 4, 1),
# "etterslep_end": datetime.date(2024, 4, 30)
# }
Demographics
KLASS utils
Kommnr
Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
License
Distributed under the terms of the MIT license, Befolkning Fagfunksjoner is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was generated from Statistics Norway's SSB PyPI Template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ssb_befolkning_fagfunksjoner-0.1.2.tar.gz.
File metadata
- Download URL: ssb_befolkning_fagfunksjoner-0.1.2.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65f5bfbf87151d32816aa3c40f844a5811ec8030e6ba63d492e38b47478d0140
|
|
| MD5 |
0919bc1fdc6ed1983dbe4ab7487f762d
|
|
| BLAKE2b-256 |
bece434701b40ad54f51c90ea705c25006b30a63beae59dec00378bcb78af8ae
|
Provenance
The following attestation bundles were made for ssb_befolkning_fagfunksjoner-0.1.2.tar.gz:
Publisher:
release.yml on statisticsnorway/ssb-befolkning-fagfunksjoner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ssb_befolkning_fagfunksjoner-0.1.2.tar.gz -
Subject digest:
65f5bfbf87151d32816aa3c40f844a5811ec8030e6ba63d492e38b47478d0140 - Sigstore transparency entry: 831306249
- Sigstore integration time:
-
Permalink:
statisticsnorway/ssb-befolkning-fagfunksjoner@4e7c2dcb4aa329fd5f60946d8e2166f50f92abce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/statisticsnorway
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e7c2dcb4aa329fd5f60946d8e2166f50f92abce -
Trigger Event:
push
-
Statement type:
File details
Details for the file ssb_befolkning_fagfunksjoner-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ssb_befolkning_fagfunksjoner-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21ad2289f2a89982937125ee7ba83b8baef4dffe9ae3ff46961dbcb2313e7d6
|
|
| MD5 |
1f64593745d1bdab7be34a8842442f81
|
|
| BLAKE2b-256 |
3c09553eb68f961548185967660f03c4319073c511680fef7e870d9373ee4d9f
|
Provenance
The following attestation bundles were made for ssb_befolkning_fagfunksjoner-0.1.2-py3-none-any.whl:
Publisher:
release.yml on statisticsnorway/ssb-befolkning-fagfunksjoner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ssb_befolkning_fagfunksjoner-0.1.2-py3-none-any.whl -
Subject digest:
b21ad2289f2a89982937125ee7ba83b8baef4dffe9ae3ff46961dbcb2313e7d6 - Sigstore transparency entry: 831306252
- Sigstore integration time:
-
Permalink:
statisticsnorway/ssb-befolkning-fagfunksjoner@4e7c2dcb4aa329fd5f60946d8e2166f50f92abce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/statisticsnorway
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e7c2dcb4aa329fd5f60946d8e2166f50f92abce -
Trigger Event:
push
-
Statement type: