Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| def get_all_heating_systems() -> list[str]: | |
| """ | |
| Returns a list of available heating systems. | |
| Currently returns a static list. Will be loaded from CSV in the future. | |
| """ | |
| return [ | |
| "Luft-Wasser Wärmepumpe", | |
| "Wasser-Wasser Wärmepumpe", | |
| "Sole-Wasser Wärmepumpe", | |
| "Pelletheizung", | |
| "Holzhackschnitzelheizung", | |
| "Wasserstoffheizung", | |
| "Gasheizung", | |
| "Ölheizung" | |
| ] | |
| COLUMN_MAP_INPUT = { | |
| "Objekt-ID": "object_id", | |
| "Object-ID": "object_id", | |
| "Wohnflaeche": "floor_area", | |
| "Wohnfläche": "floor_area", | |
| "Living area": "floor_area", | |
| "Baujahr": "year_built", | |
| "Year built": "year_built", | |
| "Gesamtwaermebedarf": "heat_demand", | |
| "Gesamtwärmebedarf": "heat_demand", | |
| "Total heat demand": "heat_demand", | |
| "spezifischer Waermebedarf": "specific_demand", | |
| "spezifischer Wärmebedarf": "specific_demand", | |
| "Specific heat demand": "specific_demand", | |
| "Heizlast" : "heat_load", | |
| "Heat load": "heat_load", | |
| } | |
| def map_input_columns(df, column_map): | |
| df_ = df.copy() | |
| df_.rename(columns=column_map, inplace = True) | |
| return df_ | |
| def get_multilang_scenario_choices(df, lang="de"): | |
| """ | |
| Gibt Liste von (Anzeigename, ID) für Radio/Selectbox. | |
| """ | |
| col = f"Szenario_{lang.upper()}" | |
| return [(row[col], row["Szenario_ID"]) for _, row in df.iterrows()] | |
| def get_scenario_row(df, szenario_id): | |
| """ | |
| Gibt vollständigen Szenario-Row als Series (oder None) für gegebene ID zurück. | |
| """ | |
| matches = df[df["Szenario_ID"] == szenario_id] | |
| return matches.iloc[0] if not matches.empty else None | |
| def get_selected_scenario(scenario_df, lang, scenario): | |
| scenario_row = scenario_df[scenario_df[f"Szenario_{lang.upper()}"] == scenario] | |
| if not scenario_row.empty: | |
| scen_values = scenario_row.iloc[0].to_dict() | |
| scen_id = scen_values.get("Szenario_ID", "A") | |
| else: | |
| scen_values = {} | |
| scen_id = "A" | |
| return scen_values, scen_id | |
| def parsefloat(cell): | |
| try: | |
| if pd.isnull(cell) or (isinstance(cell, str) and not cell.strip()): | |
| return None | |
| return float(str(cell).replace(",", ".")) | |
| except Exception: | |
| return None | |
| def float_to_comma(value): | |
| try: | |
| if value is None: | |
| return "" | |
| return str(value).replace(".", ",") | |
| except Exception: | |
| return "" | |
| def apply_technology_name_language(df, ui): | |
| if df is None or "Name" not in df.columns: | |
| return df | |
| name_map = ui["technology_names"] | |
| df = df.copy() | |
| df["Name"] = df["Name"].map(lambda n: name_map.get(n, n)) | |
| return df |