From ea45add0503fa8bd206acb70f3ea466246890b9e Mon Sep 17 00:00:00 2001 From: Jan Sebastian Rothe Date: Thu, 20 Jun 2024 13:13:36 +0200 Subject: [PATCH] Error where clean_nace couldn't handle missing --- pyproject.toml | 2 +- src/arbmark/groups/nace.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 47a85a0..85deaf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ssb-arbmark-fagfunksjoner" -version = "0.0.19" +version = "0.0.20" description = "SSB Arbeidsmarked og lønn Fag-fellesfunksjoner" authors = ["Jan Sebastian Rothe "] license = "MIT" diff --git a/src/arbmark/groups/nace.py b/src/arbmark/groups/nace.py index e926a48..1a2a6c6 100644 --- a/src/arbmark/groups/nace.py +++ b/src/arbmark/groups/nace.py @@ -38,15 +38,15 @@ def clean_nace_17_groups(val: str) -> str: """ # Check if the hyphen is in the string - if "-" in val: + if "-" in str(val): # Split the string at the hyphen - parts = val.split("-") + parts = str(val).split("-") # Check if parts before and after hyphen are the same if parts[0] == parts[1]: # Return the part before the hyphen if true return parts[0] # Return original value if no modifications are made - return val + return str(val) def nace_to_17_groups(nace: PdSeriesStr, label: bool = False) -> PdSeriesStr: @@ -83,7 +83,7 @@ def nace_to_17_groups(nace: PdSeriesStr, label: bool = False) -> PdSeriesStr: return nace_groups.map(mapping_label["name"]).fillna("Uoppgitt") else: # If labels are not requested, return the group codes directly - return nace_groups.apply(clean_nace_17_groups) + return nace_groups.fillna("00").apply(clean_nace_17_groups) def nace_sn07_47grp(nace_sn07: PdSeriesStr, display: str = "label") -> NpArrayStr: