|
22 | 22 |
|
23 | 23 | from ..configs import BSSMetadataConfig |
24 | 24 | from ..partitions import bss_files_partitions_def, bss_instances_partitions_def |
| 25 | +from .base import SUMMARY_LABELS |
25 | 26 |
|
26 | 27 | # set the default Django settings module |
27 | 28 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hea.settings.production") |
@@ -88,16 +89,20 @@ def get_wealth_group_dataframe( |
88 | 89 | wealth_group_df = wealth_group_df.loc[:, ~wealth_group_df.columns.duplicated()] |
89 | 90 | except ValueError: |
90 | 91 | 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 |
92 | 93 | wealth_group_missing_category_df = wealth_group_df[ |
93 | 94 | wealth_group_df["wealth_group_category"].isnull() |
94 | 95 | & 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 |
95 | 100 | ] |
96 | 101 | if not wealth_group_missing_category_df.empty: |
97 | 102 | unique_values = set(wealth_group_missing_category_df["wealth_group_category_original"].unique()) |
98 | 103 | raise ValueError( |
99 | 104 | "%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)) |
101 | 106 | ) |
102 | 107 | # Lookup the Community instances |
103 | 108 | community_lookup = CommunityLookup() |
|
0 commit comments