Skip to content

Commit

Permalink
resolve 'relative share' problem
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-vdm committed Dec 6, 2024
1 parent d11b506 commit 4b3f914
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activity_browser/layouts/tabs/LCA_results_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def update_dataframe(self, *args, **kwargs):
raise NotImplementedError

def update_table(self):
super().update_table(self.df)
super().update_table(self.df, relative=self.relative)

def update_plot(self):
"""Update the plot."""
Expand Down
7 changes: 6 additions & 1 deletion activity_browser/ui/tables/models/lca_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def sync(self, df):


class ContributionModel(PandasModel):
def sync(self, df):
def sync(self, df, relative=False):

# overwrite the unit col with 'relative share' if looking at relative results (except 3 'total' and 'rest' rows)
if relative:
df["unit"] = [""] * 3 + ["relative share"] * (len(df) - 3)

# drop any rows where all numbers are 0
self._dataframe = df.loc[~(df.select_dtypes(include=np.number) == 0).all(axis=1)]
self.updated.emit()

0 comments on commit 4b3f914

Please sign in to comment.