Skip to content

Commit

Permalink
Merge pull request #132 from FEWS-NET/report-missing-wealth-group-cat…
Browse files Browse the repository at this point in the history
…egory-after-lookup

Report missing wealth group category after lookup
  • Loading branch information
rhunwicks authored Nov 22, 2024
2 parents 2c0270d + 934c64d commit e2d38d9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pipelines/assets/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,17 @@ def get_wealth_group_dataframe(
wealth_group_df = wealth_group_df.loc[:, ~wealth_group_df.columns.duplicated()]
except ValueError:
pass

# Check if there are unrecognized wealth group category at this point and report
wealth_group_missing_category_df = wealth_group_df[
wealth_group_df["wealth_group_category"].isnull()
& wealth_group_df["wealth_group_category_original"].notnull()
]
if not wealth_group_missing_category_df.empty:
unique_values = set(wealth_group_missing_category_df["wealth_group_category_original"].unique())
raise ValueError(
"%s has unrecognized wealth group category in %s:\n%s"
% (partition_key, worksheet_name, "\n ".join(unique_values)),
)
# Lookup the Community instances
community_lookup = CommunityLookup()
wealth_group_df["livelihood_zone_baseline"] = livelihood_zone_baseline.id # required parent for lookup
Expand Down

0 comments on commit e2d38d9

Please sign in to comment.