(
grouped,
subplots: bool = True,
column=None,
fontsize: int | None = None,
rot: int = 0,
grid: bool = True,
ax=None,
figsize: tuple[float, float] | None = None,
layout=None,
sharex: bool = False,
sharey: bool = True,
**kwds,
)
| 507 | |
| 508 | |
| 509 | def boxplot_frame_groupby( |
| 510 | grouped, |
| 511 | subplots: bool = True, |
| 512 | column=None, |
| 513 | fontsize: int | None = None, |
| 514 | rot: int = 0, |
| 515 | grid: bool = True, |
| 516 | ax=None, |
| 517 | figsize: tuple[float, float] | None = None, |
| 518 | layout=None, |
| 519 | sharex: bool = False, |
| 520 | sharey: bool = True, |
| 521 | **kwds, |
| 522 | ): |
| 523 | if subplots is True: |
| 524 | naxes = len(grouped) |
| 525 | fig, axes = create_subplots( |
| 526 | naxes=naxes, |
| 527 | squeeze=False, |
| 528 | ax=ax, |
| 529 | sharex=sharex, |
| 530 | sharey=sharey, |
| 531 | figsize=figsize, |
| 532 | layout=layout, |
| 533 | ) |
| 534 | data = {} |
| 535 | for (key, group), ax in zip(grouped, flatten_axes(axes), strict=False): |
| 536 | d = group.boxplot( |
| 537 | ax=ax, column=column, fontsize=fontsize, rot=rot, grid=grid, **kwds |
| 538 | ) |
| 539 | ax.set_title(pprint_thing(key)) |
| 540 | data[key] = d |
| 541 | ret = pd.Series(data) |
| 542 | maybe_adjust_figure(fig, bottom=0.15, top=0.9, left=0.1, right=0.9, wspace=0.2) |
| 543 | else: |
| 544 | keys, frames = zip(*grouped, strict=True) |
| 545 | df = pd.concat(frames, keys=keys, axis=1) |
| 546 | |
| 547 | # GH 16748, DataFrameGroupby fails when subplots=False and `column` argument |
| 548 | # is assigned, and in this case, since `df` here becomes MI after groupby, |
| 549 | # so we need to couple the keys (grouped values) and column (original df |
| 550 | # column) together to search for subset to plot |
| 551 | if column is not None: |
| 552 | column = com.convert_to_list_like(column) |
| 553 | multi_key = pd.MultiIndex.from_product([keys, column]) |
| 554 | column = list(multi_key.values) |
| 555 | ret = df.boxplot( |
| 556 | column=column, |
| 557 | fontsize=fontsize, |
| 558 | rot=rot, |
| 559 | grid=grid, |
| 560 | ax=ax, |
| 561 | figsize=figsize, |
| 562 | layout=layout, |
| 563 | **kwds, |
| 564 | ) |
| 565 | return ret |
nothing calls this directly
no test coverage detected