@@ -50,15 +50,13 @@ Check if you are on Dapla or in prodsone.
5050``` python
5151from fagfunksjoner import check_env
5252
53-
5453check_env()
5554```
5655
5756Navigate to the root of your project and back again. Do stuff while in root, like importing local functions.
5857``` python
5958from fagfunksjoner import ProjectRoot
6059
61-
6260with ProjectRoot():
6361 ... # Do your local imports here...
6462```
@@ -69,7 +67,6 @@ Setting up password with saspy
6967``` python
7068from fagfunksjoner.prodsone import saspy_ssb
7169
72-
7370saspy_ssb.set_password() # Follow the instructions to set the password
7471saspy_ssb.saspy_df_from_path(" path" )
7572```
@@ -80,7 +77,6 @@ import logging
8077
8178from fagfunksjoner.log.statlogger import StatLogger
8279
83-
8480# Ved å opprette StatLogger så "hijacker" den den vanlige loggeren
8581root_logger = StatLogger(log_file = " custom_log_file.log" )
8682# I tillegg sørger vi for at den ikke blir ryddet bort av Python, ved å assigne den til en variabel?
@@ -95,7 +91,6 @@ logger.info("This is an info message")
9591``` python
9692from fagfunksjoner import make_klass_xml_codelist
9793
98-
9994make_klass_xml_codelist(path = " kjoenn.xml" ,
10095 codes = [" 1" , " 2" ],
10196 names_bokmaal = [" Mann" , " Kvinne" ])
@@ -109,7 +104,6 @@ import pandas as pd
109104
110105from fagfunksjoner import round_up
111106
112-
113107print (round (2.5 , 0 ), round_up(2.5 , 0 ))
114108
115109round_up(pd.Series([1.5 , 2.5 , 3.5 ]), 0 ) # Datatype blir Int64 når man runder til 0 desimaler
@@ -132,7 +126,6 @@ Aggregate on all exclusive combinations of codes in certain columns (maybe befor
132126``` python
133127from fagfunksjoner import all_combos_agg
134128
135-
136129ialt_koder = {
137130" skolefylk" : " 01-99" ,
138131" almyrk" : " 00" ,
@@ -151,7 +144,6 @@ To aggregate on NON-EXCLUSIVE combinations of codes in certain columns, use the
151144``` python
152145from fagfunksjoner import all_combos_agg_inclusive
153146
154-
155147category_mappings = {
156148 " Alder" : {
157149 " 15-24" : range (15 , 25 ),
@@ -202,7 +194,6 @@ Perform mapping using SsbFormat. Behaves like a dictionary. Has functionality fo
202194``` python
203195from fagfunksjoner import SsbFormat
204196
205-
206197age_frmt = {
207198' low-18' : ' -18' ,
208199' 19-25' : ' 19-25' ,
@@ -224,7 +215,6 @@ print(df['age_group'].value_counts())
224215# save format
225216from fagfunksjoner.formats import store_format
226217
227-
228218store_format(path+ ' format_name_p2025-02.json' )
229219
230220# or
@@ -234,7 +224,6 @@ ssb_age_frmt.store(path + 'format_name_p2025-02.json', force=True)
234224# read format/import format (dictionary saved as .json) as SsbFormat
235225from fagfunksjoner.formats import get_format
236226
237-
238227some_frmt = get_format(path+ ' format_name.json' )
239228```
240229
@@ -245,7 +234,6 @@ We have "flat files", which are not comma seperated. These need metadata to corr
245234``` python
246235from fagfunksjoner import open_path_datadok
247236
248-
249237archive_object = open_path_datadok(" $TBF/project/arkiv/filename/g2022g2023" )
250238# The object now has several important attributes
251239archive_object.df # The Dataframe of the archived data
@@ -274,7 +262,6 @@ from dotenv import load_dotenv
274262
275263from fagfunksjoner.prodsone import Oracle
276264
277-
278265load_dotenv()
279266
280267query = " select vare, pris from my_db_table"
@@ -296,7 +283,6 @@ from dotenv import load_dotenv
296283
297284from fagfunksjoner.prodsone import Oracle
298285
299-
300286load_dotenv()
301287
302288query = " select vare, pris from my_db_table"
@@ -319,7 +305,6 @@ from dotenv import load_dotenv
319305
320306from fagfunksjoner.prodsone import Oracle
321307
322-
323308load_dotenv()
324309
325310df = pd.DataFrame(
0 commit comments