Skip to content

Commit

Permalink
Address pandas apply include_groups warning
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Nov 20, 2024
1 parent 0d66101 commit 65dabab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 2 additions & 5 deletions ixmp/report/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ def dims_for_qty(data):
:data:`.RENAME_DIMS` is used to rename dimensions.
"""
if isinstance(data, pd.DataFrame):
# List of the dimensions
dims = data.columns.tolist()
else:
dims = list(data)
# List of the dimensions
dims = data.columns.tolist() if isinstance(data, pd.DataFrame) else list(data)

# Remove columns containing values or units; dimensions are the remainder
for col in "value", "lvl", "mrg", "unit":
Expand Down
13 changes: 7 additions & 6 deletions ixmp/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,15 @@ def describe(df):
info = (
platform.scenario_list(model=model, scen=scenario, default=default_only)
.groupby(["model", "scenario"], group_keys=True)
.apply(describe)
.apply(describe, include_groups=False)
)

if len(info):
info = info.reset_index()
else:
# No results; re-create a minimal empty data frame
info = pd.DataFrame([], columns=["model", "scenario", "default", "N"])
# If we have no results; re-create a minimal empty data frame
info = (
info.reset_index()
if len(info)
else pd.DataFrame([], columns=["model", "scenario", "default", "N"])
)

info["scenario"] = info["scenario"].str.cat(info["default"].astype(str), sep="#")

Expand Down

0 comments on commit 65dabab

Please sign in to comment.