diff --git a/recommendations/recommendation_utils.py b/recommendations/recommendation_utils.py index d5788544..00da6107 100644 --- a/recommendations/recommendation_utils.py +++ b/recommendations/recommendation_utils.py @@ -205,7 +205,7 @@ def get_wall_u_value( mapped_value = wall_uvalues_df[ wall_uvalues_df["Wall_type"] == mapped_description - ][age_band].values[0] + ][age_band].values[0] if pd.isnull(mapped_value) and "Park home" in mapped_description: # We don't know enough in this case so we default to 0 @@ -257,7 +257,7 @@ def extract_thickness(thickness, is_roof_room, is_at_rafters, is_loft, is_flat): try: thickness = int(thickness) return thickness - except ValueError: + except (TypeError, ValueError): # If thickness is not a valid number (could be a string or None), return None return None @@ -350,7 +350,7 @@ def get_roof_u_value( is_roof_room=is_roof_room, is_at_rafters=is_at_rafters, is_loft=is_loft, - is_flat=is_flat + is_flat=is_flat, ) # Step 1: Try to get the U-value from table S9 based on the insulation thickness @@ -395,9 +395,9 @@ def get_roof_u_value( # Get the U-value from table S10 based on the age band and the determined column if is_flat and thickness is not None: u_value = s10.loc[ - (s10["Insulation_Thickness"] == thickness) | - s10["Age_band"].str.contains(age_band), - column + (s10["Insulation_Thickness"] == thickness) + | s10["Age_band"].str.contains(age_band), + column, ].values.min() else: u_value = s10.loc[s10["Age_band"].str.contains(age_band), column].values[0] @@ -560,7 +560,7 @@ def get_floor_u_value( insulation_lookup = s11[ s11["Age_band"].str.contains(age_band) & s11["Floor_construction"] == floor_type - ] + ] if insulation_lookup.empty: insulation_thickness = 0 else: