Assign GenX tags ignoring underscores
@@ -1166,7 +1166,8 @@ def add_genx_model_tags(df, settings):
dataframe
The original generator cluster results with new columns for each model tag.
"""
- technology = df["technology"].str.replace(r"\s+", "")
+ ignored = r"\s+|_"
+ technology = df["technology"].str.replace(ignored, "")
# Create a new dataframe with the same index
default = settings.get("default_model_tag", 0)
for tag_col in settings.get("model_tag_names", []):
@@ -1174,7 +1175,7 @@ def add_genx_model_tags(df, settings):
try:
for tech, tag_value in settings["model_tag_values"][tag_col].items():
- tech = re.sub(r"\s+", "", tech)
+ tech = re.sub(ignored, "", tech)
mask = technology.str.contains(fr"^{tech}", case=False)
df.loc[mask, tag_col] = tag_value
except (KeyError, AttributeError) as e:
@@ -1185,7 +1186,7 @@ def add_genx_model_tags(df, settings):
for tag_tuple, tag_value in flat_regional_tags.items():
region, tag_col, tech = tag_tuple
- tech = re.sub(r"\s+", "", tech)
+ tech = re.sub(ignored, "", tech)
mask = technology.str.contains(fr"^{tech}", case=False)
df.loc[(df["region"] == region) & mask, tag_col,] = tag_value
