Skip to content

Commit e2d38d9

Browse files
authored
Merge pull request #132 from FEWS-NET/report-missing-wealth-group-category-after-lookup
Report missing wealth group category after lookup
2 parents 2c0270d + 934c64d commit e2d38d9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pipelines/assets/baseline.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ def get_wealth_group_dataframe(
8888
wealth_group_df = wealth_group_df.loc[:, ~wealth_group_df.columns.duplicated()]
8989
except ValueError:
9090
pass
91-
91+
# Check if there are unrecognized wealth group category at this point and report
92+
wealth_group_missing_category_df = wealth_group_df[
93+
wealth_group_df["wealth_group_category"].isnull()
94+
& wealth_group_df["wealth_group_category_original"].notnull()
95+
]
96+
if not wealth_group_missing_category_df.empty:
97+
unique_values = set(wealth_group_missing_category_df["wealth_group_category_original"].unique())
98+
raise ValueError(
99+
"%s has unrecognized wealth group category in %s:\n%s"
100+
% (partition_key, worksheet_name, "\n ".join(unique_values)),
101+
)
92102
# Lookup the Community instances
93103
community_lookup = CommunityLookup()
94104
wealth_group_df["livelihood_zone_baseline"] = livelihood_zone_baseline.id # required parent for lookup

0 commit comments

Comments
 (0)