Skip to content

Commit

Permalink
with cont for next time
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantinstadler committed Feb 16, 2024
1 parent a43c166 commit 1a26823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion pymrio/tools/ioutil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
""
Utility function for pymrio

KST 20140502
Expand Down Expand Up @@ -1137,6 +1137,8 @@ def match_and_convert(df_orig, df_map, agg_func='sum'):
df_collected = df_collected.reorder_levels(new_name_order, axis=0)

# CONT: new test cases and logic for compartment included
# Idea is to pass through all index levels which are not specified in the map or in the __ columns
# To remove a level, provide __ and give it one common name (e.g. "DROP") and then remove
res_collector.append(df_collected.groupby(by=df_collected.index.names).agg(agg_method))

return pd.concat(res_collector, axis=0)
Expand Down
18 changes: 9 additions & 9 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ def test_char_table():
exp_res1 = exp_res1.astype(float)
exp_res1.sort_index(inplace=True)

res1 = match_and_convert(to_char, map_test1)
res1.sort_index(inplace=True)


exp_res1.index.names = res1.index.names

exp_res1.columns.names = res1.columns.names

pdt.assert_frame_equal(res1, exp_res1)
# res1 = match_and_convert(to_char, map_test1)
# res1.sort_index(inplace=True)
#
#
# exp_res1.index.names = res1.index.names
#
# exp_res1.columns.names = res1.columns.names
#
# pdt.assert_frame_equal(res1, exp_res1)

# TEST2 with impact per compartment (two index levels in the result)

Expand Down

0 comments on commit 1a26823

Please sign in to comment.