import pandas as pd class DemandAssessment: def __init__(self): self.raw_score = pd.read_csv("data/demand_raw.csv") def print_data(self): return self.raw_score def get_demand_score(self, region, city, district): def calculate_normalized_score(score: float, flag: str ) -> str: map = dict(city=[0, 2.70238], region=[0, 1.234568], country=[0, 0.289575]) threshold = map[flag] if score >= threshold[1]: return "High" elif threshold[0] < score < threshold[1]: return "Moderate" else: return "Low" if region: temp = self.raw_score[ (self.raw_score["Region"] == region) & (self.raw_score["City"] == city) & (self.raw_score["District"] == district) ] else: temp = self.raw_score[ (self.raw_score["City"] == city) & (self.raw_score["District"] == district) ] temp = temp.iloc[0] return { "City_Normalized_Score": temp["City Scaled Score"], "Region_Normalized_Score": temp["Region Scaled Score"], "Country_Normalized_Score": temp["Region Scaled Score"], "City_Demand_Label": calculate_normalized_score(temp["City Scaled Score"], "city"), "Region_Demand_Label": calculate_normalized_score(temp["Region Scaled Score"], "region"), "Country_Demand_Label": calculate_normalized_score(temp["Region Scaled Score"], "country"), }