Skip to main content

Fellesfunksjoner for ssb i Python

Project description

SSB Fag-fellesfunksjoner i Python

A place for "loose, small functionality" produced at Statistics Norway in Python. Functionality might start here, if it is to be used widely within the organization, but later be moved to bigger packages if they "grow out of proportions".

Team: ssb-pythonistas

We are a team of statiticians which hope to curate and generalize functionality which arizes from specific needs in specific production-environments. We try to take responsibility for this functionality to be generalized and available to all of statistics Norway through this package.

Pypi-account Github-team

Contributing

Please make contact with one of our team members, to see if you can join, or how to send in a PR for approval into the package.

Installing

poetry add ssb-fagfunksjoner

Usage

Check if you are on Dapla or in prodsone.

from fagfunksjoner import check_env
check_env()

Navigate to the root of your project and back again. Do stuff while in root, like importing local functions.

from fagfunksjoner import ProjectRoot
with ProjectRoot():
    ... # Do your local imports here...

Querying internal oracle-database "DB1P"

from fagfunksjoner import query_db1p
sporring = "SELECT SNR_NUDB FROM NUDB_ADM.TAB_UTD_PERSON"
df = query_db1p(sporring)

Setting up password with saspy

from fagfunksjoner.prodsone import saspy_ssb
saspy_ssb.set_password() # Follow the instructions to set the password
saspy_ssb.saspy_df_from_path("path")

Aggregate on all combinations of codes in certain columns (maybe before sending to statbank? Like proc means?)

from fagfunksjoner import all_combos_agg
ialt_koder = {
"skolefylk": "01-99",
"almyrk": "00",
"kjoenn_t": "0",
"sluttkomp": "00",
}
kolonner = list(ialt_koder.keys())
tab = all_combos_agg(vgogjen, 
                     groupcols=kolonner, 
                     aggargs={'antall': sum}, 
                     fillna_dict=ialt_koder)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssb_fagfunksjoner-0.1.0.tar.gz (20.6 kB view hashes)

Uploaded Source

Built Distribution

ssb_fagfunksjoner-0.1.0-py3-none-any.whl (25.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page