Skip to content

Commit

Permalink
Merge pull request #60 from statisticsnorway/nace-group-fix
Browse files Browse the repository at this point in the history
Error where clean_nace couldn't handle missing
  • Loading branch information
sebrothe authored Jun 21, 2024
2 parents eba87da + ea45add commit 56205f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
8 changes: 4 additions & 4 deletions src/arbmark/groups/nace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 56205f7

Please sign in to comment.