Skip to content

Commit

Permalink
Merge pull request #96 from davide-f/master
Browse files Browse the repository at this point in the history
add convert to short name in GEO
  • Loading branch information
FabianHofmann authored Jan 24, 2023
2 parents 5427665 + 83054d7 commit d9be824
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion powerplantmatching/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def to_year(ds):
not_included_ppl = ppl.query("projectID not in @res.projectID")
res = pd.concat([res, not_included_ppl]).pipe(set_column_name, "GEO")
res = scale_to_net_capacities(res)
res = convert_to_short_name(res)
res = set_column_name(res, "GEO")
res = config_filter(res, config)
res["projectID"] = "GEO-" + res.projectID.astype(str)
Expand Down Expand Up @@ -586,9 +587,10 @@ def GPD(raw=False, update=False, config=None, filter_other_dbs=True):
countries = config["target_countries"]
return (
df.rename(columns=lambda x: x.title())
.query("Country_Long in @countries &" " Source not in @other_dbs")
.drop(columns="Country")
.rename(columns=RENAME_COLS)
.pipe(convert_to_short_name)
.query("Country in @countries &" " Source not in @other_dbs")
.pipe(
gather_specifications,
parse_columns=["Name", "Fueltype"],
Expand Down
4 changes: 3 additions & 1 deletion powerplantmatching/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def cross_matches(sets_of_pairs, labels=None):
match_base = pd.concat(base, axis=1).reset_index()
matches = pd.concat([matches, match_base], sort=True)

assert not matches.empty, "No matches found"
if matches.empty:
logger.warn("No matches found")
return pd.DataFrame(columns=labels)

if matches.isnull().all().any():
cols = ", ".join(matches.columns[matches.isnull().all()])
Expand Down

0 comments on commit d9be824

Please sign in to comment.