DEPR: Change boxplot return_type kwarg by TomAugspurger · Pull Request #12216 · pandas-dev/pandas (original) (raw)
Well, here's a not so great thing. I think we'll have to keep the behavior of return_type=None
not being the same as return_type='axes'
when by
is not None.
before
a = df.groupby('d').boxplot() # OD[dict] warned b = df.boxplot() # dict, warned c = df.boxplot(by='d') # [axes], didn't warn c = df.boxplot(by='d', return_type='axes') # OD[axes]
and
after
a = df.groupby('d').boxplot() # OD[axes] b = df.boxplot() # axes c = df.boxplot(by='d') # [axes] c = df.boxplot(by='d', return_type='axes') # OD[axes]
I had hoped to just make the default 'axes', but since I din't warn in the 3rd example, I don't think we can change that. Are we OK with that? Here's the updated docs:
Plot functions return scalar or arrays of :class:matplotlib Axes <matplotlib.axes.Axes>
.
In boxplot
, the return type can be controlled by the return_type
, keyword. The valid choices are {"axes", "dict", "both"}
.
'axes'
returns a single matplotlib axes.
'dict'
returns a dict of matplotlib artists, similar to the matplotlib boxplot function.
'both'
returns a named tuple of axes and dicts.
When by
is not None, you get back an OrderedDict
of whatever return_type
is, unless return_type
is just None
, in which case you get back an array of axes.