Skip to content

Commit

Permalink
Condense code based on review in #186
Browse files Browse the repository at this point in the history
  • Loading branch information
measrainsey committed Apr 25, 2024
1 parent 94d9675 commit 3278ab1
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions message_ix_models/tools/costs/projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,21 +468,11 @@ def create_message_outputs(
)
.astype(dtypes)
.query("year_vtg in @config.Y")
.assign(first_technology_year=lambda x: x.first_technology_year.astype(float))
.assign(first_technology_year=lambda x: x.first_technology_year.astype(int))
.astype({"first_technology_year": float})
.query("year_vtg >= first_technology_year")
.reset_index(drop=True)
.drop_duplicates()[
[
"scenario_version",
"scenario",
"node_loc",
"technology",
"year_vtg",
"value",
"unit",
]
]
.drop_duplicates()
.drop("first_technology_year", axis=1)
)

dtypes.update(year_act=int)
Expand All @@ -491,7 +481,8 @@ def create_message_outputs(
.drop(columns=["inv_cost"])
.assign(key=1)
.merge(
pd.DataFrame(data={"year_act": config.seq_years}).assign(key=1), on="key"
pd.DataFrame(data={"year_act": config.seq_years}).assign(key=1),
on="key",
)
.drop(columns=["key"])
.query("year_act >= year_vtg")
Expand Down Expand Up @@ -540,22 +531,12 @@ def create_message_outputs(
)
.astype(dtypes)
.query("year_act in @config.Y and year_vtg in @config.Y")
.assign(first_technology_year=lambda x: x.first_technology_year.astype(float))
.assign(first_technology_year=lambda x: x.first_technology_year.astype(int))
.astype({"first_technology_year": float})
.query("year_vtg >= first_technology_year")
.reset_index(drop=True)
).drop_duplicates()[
[
"scenario_version",
"scenario",
"node_loc",
"technology",
"year_vtg",
"year_act",
"value",
"unit",
]
]
.drop_duplicates()
.drop("first_technology_year", axis=1)
)

return inv, fom

Expand Down

0 comments on commit 3278ab1

Please sign in to comment.