Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Mar 14, 2023
2 parents 67c7e52 + e646e6f commit fe89bc4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions unfold/unfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
check_exchanges_input,
check_for_duplicates,
correct_fields_format,
get_list_of_unique_datasets,
remove_categories_for_technosphere_flows,
remove_missing_fields,
get_list_of_unique_datasets,
)
from .export import UnfoldExporter
from .utils import HiddenPrints
Expand Down Expand Up @@ -693,11 +693,19 @@ def filter_out_datasets(
"""

# Get the list of datasets not used in the current scenario.
df_gr = self.scenario_df.groupby("to activity name").sum(numeric_only=True).loc[:, [scenario_name]]
datasets_not_in_scenario = df_gr.loc[df_gr[scenario_name] == 0, :].index.tolist()
df_gr = (
self.scenario_df.groupby("to activity name")
.sum(numeric_only=True)
.loc[:, [scenario_name]]
)
datasets_not_in_scenario = df_gr.loc[
df_gr[scenario_name] == 0, :
].index.tolist()

# Remove datasets that are not in the current scenario.
database = [act for act in database if act["name"] not in datasets_not_in_scenario]
database = [
act for act in database if act["name"] not in datasets_not_in_scenario
]

return database

Expand Down

0 comments on commit fe89bc4

Please sign in to comment.