From af2022b7d4d6841cd0a8ebf991b06637e28b2766 Mon Sep 17 00:00:00 2001 From: Matthew Gidden Date: Fri, 29 Nov 2024 12:53:28 +0100 Subject: [PATCH] hotfix box plotting to support latest pandas set_categories --- pyam/plotting.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pyam/plotting.py b/pyam/plotting.py index b5f739d4f..cd9aa3ea6 100644 --- a/pyam/plotting.py +++ b/pyam/plotting.py @@ -19,13 +19,7 @@ from pyam.run_control import run_control from pyam.str import is_str from pyam.timeseries import cross_threshold -from pyam.utils import ( - IAMC_IDX, - META_IDX, - SORT_IDX, - YEAR_IDX, - to_list, -) +from pyam.utils import IAMC_IDX, META_IDX, SORT_IDX, YEAR_IDX, to_list logger = logging.getLogger(__name__) @@ -711,7 +705,7 @@ def box(df, y="value", x=None, by=None, legend=True, title=None, ax=None, **kwar # TODO this only works if all categories are defined in run_control palette = rc["color"][by] df[by] = df[by].astype("category") - df[by].cat.set_categories(list(palette), inplace=True) + df[by] = df[by].cat.set_categories(list(palette)) kwargs["palette"] = palette else: df.sort_values(by, inplace=True)