Skip to content

Commit 74b7df3

Browse files
authored
Merge pull request #133 from FEWS-NET/report-missing-wealth-group-category-after-lookup
Add exclusion of SUMMARY_LABELS and "" values for wealth group missin…
2 parents e2d38d9 + b456530 commit 74b7df3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pipelines/assets/baseline.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from ..configs import BSSMetadataConfig
2424
from ..partitions import bss_files_partitions_def, bss_instances_partitions_def
25+
from .base import SUMMARY_LABELS
2526

2627
# set the default Django settings module
2728
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hea.settings.production")
@@ -88,16 +89,20 @@ def get_wealth_group_dataframe(
8889
wealth_group_df = wealth_group_df.loc[:, ~wealth_group_df.columns.duplicated()]
8990
except ValueError:
9091
pass
91-
# Check if there are unrecognized wealth group category at this point and report
92+
# Check if there are unrecognized wealth group categories and report
9293
wealth_group_missing_category_df = wealth_group_df[
9394
wealth_group_df["wealth_group_category"].isnull()
9495
& wealth_group_df["wealth_group_category_original"].notnull()
96+
& ~wealth_group_df["wealth_group_category_original"]
97+
.str.lower()
98+
.isin([label.lower() for label in SUMMARY_LABELS]) # Exclude rows with summary labels (case-insensitive)
99+
& (wealth_group_df["wealth_group_category_original"].str.strip() != "") # Exclude rows with empty strings
95100
]
96101
if not wealth_group_missing_category_df.empty:
97102
unique_values = set(wealth_group_missing_category_df["wealth_group_category_original"].unique())
98103
raise ValueError(
99104
"%s has unrecognized wealth group category in %s:\n%s"
100-
% (partition_key, worksheet_name, "\n ".join(unique_values)),
105+
% (partition_key, worksheet_name, "\n".join(unique_values))
101106
)
102107
# Lookup the Community instances
103108
community_lookup = CommunityLookup()

0 commit comments

Comments
 (0)