arbmark.groups package¶
Submodules¶
arbmark.groups.age module¶
- alder_5grp(alder, display='label')¶
Categorize a pandas Series of person ages into predefined groups used in ARBLONN.
- Parameters:
alder (
Series
) – A pandas Series containing the person ages.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original person ages are replaced by group labels, keys, or a combination.
- alder_grp(alder, display='label')¶
Categorize a pandas Series of person ages into predefined groups used in SYKEFR.
- Parameters:
alder (
Series
) – A pandas Series containing the person ages.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original person ages are replaced by group labels, keys, or a combination.
arbmark.groups.company_size module¶
- virk_str_8grp(ansatte, display='label')¶
Categorize a pandas Series of employee counts into predefined groups.
- Parameters:
ansatte (
Series
) – A pandas Series containing the employee counts.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original employee counts are replaced by group labels or keys.
arbmark.groups.country_origin module¶
- landbakgrunn_grp(landbakgrunn, display='label')¶
Categorize a pandas Series of country origins from 3 generations into world regions.
- Parameters:
landbakgrunn (
Series
) – A pandas Series containing the country origins.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; if ‘arblonn’, returns specific labels for ARBLONN; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original country origins are replaced by group labels or keys.
arbmark.groups.nace module¶
- clean_nace_17_groups(val)¶
Cleans the NACE code value by removing redundant parts.
This function checks if the input string val contains a hyphen (‘-’) and if the parts before and after the hyphen are identical. If they are, it returns only the part before the hyphen. Otherwise, it returns the original input value.
- Parameters:
val (
str
) – A string containing the NACE code to be cleaned.- Return type:
str
- Returns:
A string with the cleaned NACE code.
- nace_sn07_47grp(nace_sn07, display='label')¶
Categorize a pandas Series of NACE-codes (SN07) into predefined groups.
- Parameters:
nace_sn07 (
Series
) – A pandas Series containing the NACE-codes.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original NACE-codes are replaced by group labels or keys.
- nace_to_17_groups(nace, label=False)¶
Converts NACE codes in a Pandas Series to their corresponding group codes or labels.
NACE (Nomenclature of Economic Activities) is the European industry standard classification system. This function maps NACE codes to a higher-level group (level 2) and optionally returns the group’s name instead of its code.
- Parameters:
nace (
Series
) – A Pandas Series containing NACE codes.label (
bool
) – If True, returns the names of the groups instead of their codes. Defaults to False.
- Return type:
Series
- Returns:
A Pandas Series with the mapped group codes or names, depending on the ‘label’ argument.
Note
The function relies on a predefined mapping (‘KlassVariant(1616).data’) to perform the conversion. It assumes that this mapping has a specific structure, with ‘level’, ‘code’, and ‘parentCode’ (or ‘name’ if labels are requested) columns.
arbmark.groups.sector module¶
- sektor2_grp(sektor, display='label')¶
Categorize a pandas Series of sectors into predefined groups.
- Parameters:
sektor (
Series
) – A pandas Series containing the sector codes.display (
str
) – If ‘label’, returns group labels; if ‘number’, returns keys; for any other string, returns a combination of keys and labels.
- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
A numpy Array where the original sector is replaced by group labels or keys.
arbmark.groups.shift_work module¶
- turnuskoder(arb_tid_ordning)¶
Assigns codes based on work schedule categories.
This function takes a pandas Series containing work schedule categories and assigns corresponding codes based on specific conditions. The conditions are as follows: - ‘20’ is assigned to categories [‘dogn355’, ‘helkont336’, ‘offshore336’, ‘skift365’, ‘andre_skift’] - ‘25’ is assigned to the ‘ikke_skift’ category - ‘99’ is assigned to values [‘-2’, ‘’, ‘-1’] or NaN values in the series Any value that doesn’t match these conditions will be assigned an empty string.
- Parameters:
arb_tid_ordning (
Series
) – A pandas Series object containing strings that represent different work schedule categories.- Return type:
ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]- Returns:
An array of strings, where each string is a code corresponding to the work schedule category in arb_tid_ordning.
Example
>>> arb_tid_ordning = pd.Series(['dogn355', 'helkont336', 'ikke_skift', '-2', 'offshore336', '']) >>> turnuskoder(arb_tid_ordning) array(['20', '20', '25', '99', '20', '99'], dtype='<U2')
Module contents¶
A collection of useful groups.