Skip to content

Commit

Permalink
Reformat transforms.py
Browse files Browse the repository at this point in the history
  • Loading branch information
olejandro committed Feb 22, 2024
1 parent 07b53a1 commit f7308e7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions xl2times/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,15 +1248,13 @@ def complete_commodity_groups(
"""

# Single member CGs i.e., CG and commodity are the same
single_cgs = (
model.commodities[["region", "commodity"]]
.drop_duplicates(ignore_index=True)
single_cgs = model.commodities[["region", "commodity"]].drop_duplicates(
ignore_index=True
)
single_cgs["commoditygroup"] = single_cgs["commodity"]
# Commodity groups from topology
top_cgs = (
model.topology[["region", "commodity", "commoditygroup"]]
.drop_duplicates(ignore_index=True)
top_cgs = model.topology[["region", "commodity", "commoditygroup"]].drop_duplicates(
ignore_index=True
)
cgs = pd.concat([single_cgs, top_cgs], ignore_index=True)
cgs["gmap"] = cgs["commoditygroup"] != cgs["commodity"]
Expand Down Expand Up @@ -2507,10 +2505,9 @@ def resolve_remaining_cgs(
i = model.attributes["other_indexes"].isin(default_pcg_suffixes)
if any(i):
# Store processes with unresolved commodity groups
check_cgs = (
model.attributes.loc[i, ["region", "process", "other_indexes"]]
.drop_duplicates(ignore_index=True)
)
check_cgs = model.attributes.loc[
i, ["region", "process", "other_indexes"]
].drop_duplicates(ignore_index=True)
# Resolve commodity group names in model.attribues
model.attributes.loc[i, "other_indexes"] = (
model.attributes["process"].astype(str)
Expand Down

0 comments on commit f7308e7

Please sign in to comment.