From 65dabab7784244b2ab2b894103c0405941bde65a Mon Sep 17 00:00:00 2001 From: Fridolin Glatter Date: Wed, 20 Nov 2024 10:37:06 +0100 Subject: [PATCH] Address pandas apply include_groups warning --- ixmp/report/util.py | 7 ++----- ixmp/util/__init__.py | 13 +++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ixmp/report/util.py b/ixmp/report/util.py index 3e718cc80..3a2430933 100644 --- a/ixmp/report/util.py +++ b/ixmp/report/util.py @@ -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": diff --git a/ixmp/util/__init__.py b/ixmp/util/__init__.py index fc3e221e6..bdc132a20 100644 --- a/ixmp/util/__init__.py +++ b/ixmp/util/__init__.py @@ -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="#")