Skip to content

Commit 19aa20a

Browse files
committed
Fix result aggregation
1 parent 6e42f6c commit 19aa20a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

activity_browser/bwutils/multilca.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def inventory_df(
659659
) -> pd.DataFrame:
660660
"""Return an inventory dataframe with metadata of the given type."""
661661
try:
662-
data = self.inventory_data[inventory_type]
662+
data = deepcopy(self.inventory_data[inventory_type])
663663
appending = columns.difference(set(data[3]))
664664
for clmn in appending:
665665
data[3].append(clmn)
@@ -762,10 +762,10 @@ def aggregate_by_parameters(
762762

763763
df = pd.DataFrame(contributions).T
764764
columns = list(range(contributions.shape[0]))
765-
df.index = pd.MultiIndex.from_tuples(rev_index.values())
766-
metadata = AB_metadata.get_metadata(list(keys), fields)
765+
df.index = rev_index.values()
766+
metadata = AB_metadata.dataframe.loc[AB_metadata.dataframe["id"].isin(keys), fields + ["id"]]
767767

768-
joined = metadata.join(df)
768+
joined = metadata.merge(df, left_on="id", right_index=True, how="left")
769769
joined.reset_index(inplace=True, drop=True)
770770
grouped = joined.groupby(parameters)
771771
aggregated = grouped[columns].sum()

0 commit comments

Comments
 (0)