@@ -925,8 +925,10 @@ def _get_livelihoods_protection_threshold_as_percentage_kcals(self):
925925 # the current Wealth Group
926926 for column in poor_df .columns :
927927 if column != "livelihood_strategy_id" :
928- merged [f"effective_{ column } " ] = merged [f"{ column } _wealth_group" ].combine_first (
929- merged [f"{ column } _poor" ]
928+ wealth_group_values = merged [f"{ column } _wealth_group" ]
929+ poor_values = merged [f"{ column } _poor" ]
930+ merged [f"effective_{ column } " ] = wealth_group_values .where (
931+ wealth_group_values .notna (), poor_values
930932 )
931933
932934 # Calculate the expenditure for the Basket by applying the
@@ -935,10 +937,14 @@ def _get_livelihoods_protection_threshold_as_percentage_kcals(self):
935937 # was for the Poor Wealth Group the expenditure reflects the
936938 # different household sizes.
937939 merged ["basket_expenditure" ] = (
938- merged ["effective_expenditure" ]
939- * merged ["effective_percentage_allocation_to_basket" ]
940- / merged ["effective_household_size" ]
941- * self .average_household_size
940+ (
941+ merged ["effective_expenditure" ]
942+ * merged ["effective_percentage_allocation_to_basket" ]
943+ / merged ["effective_household_size" ]
944+ * self .average_household_size
945+ )
946+ if self .average_household_size
947+ else None
942948 )
943949
944950 # For the percentage_kcals we can apply the effective_percentage_allocation_to_basket
0 commit comments