IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
221 stars 115 forks source link

plot.box - deprecated pandas function call #775

Open l-welder opened 10 months ago

l-welder commented 10 months ago

In the box plot function, panda's set_categories function is called:

https://github.com/IAMconsortium/pyam/blob/525ede9a3310198bd497f04041d4a13149adad43/pyam/plotting.py#L714

However, the inplace parameter of the set_categories was removed in pandas >= 2.0 (see pandas_<2, pandas_>=2).

This leads to an issue when calling the box plot function with a by parameter when the following if call triggers:

https://github.com/IAMconsortium/pyam/blob/525ede9a3310198bd497f04041d4a13149adad43/pyam/plotting.py#L710

A simple fix is to replace the line with: df[by].cat = df[by].cat.set_categories(list(palette)).