pandas.api.typing.DataFrameGroupBy.boxplot
pandas 3.1.1 · GroupBy · method
Draw box plots to compare medians, spread and possible outliers.
Call syntax
pd.api.typing.DataFrameGroupBy.boxplot(…) Full signature
pd.api.typing.DataFrameGroupBy.boxplot(
grouped,
subplots=True,
column=None,
fontsize=None,
rot=0,
grid=True,
ax=None,
figsize=None,
layout=None,
sharex=False,
sharey=True,
backend=None,
**kwargs,
)Inspect the call
Run this code to inspect the callable and its parameters. Its data, backend, or environment is needed to execute the operation itself.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
grouped |
Required Positional or keyword |
DataFrameGroupBy |
subplots |
Optional Positional or keyword Default True |
bool |
column |
Optional Positional or keyword Default None |
column name or list of names, or vector Identify the column or columns to use. |
fontsize |
Optional Positional or keyword Default None |
float or str Set the size of labels or text in the plot. |
rot |
Optional Positional or keyword Default 0 |
float Set the rotation of tick labels in degrees. |
grid |
Optional Positional or keyword Default True |
bool Choose whether the plot displays grid lines. |
ax |
Optional Positional or keyword Default None |
Matplotlib axis object Provide the existing Matplotlib axes on which to draw. |
figsize |
Optional Positional or keyword Default None |
tuple of (float, float) Set the figure width and height as a pair, in inches. |
layout |
Optional Positional or keyword Default None |
tuple (optional) Set the subplot grid shape as a pair of dimensions. |
sharex |
Optional Positional or keyword Default False |
bool Choose whether subplots share their horizontal axis. |
sharey |
Optional Positional or keyword Default True |
bool Choose whether subplots share their vertical axis. |
backend |
Optional Positional or keyword Default None |
str |
**kwargs |
Optional Additional keyword arguments |
Returns
dict or DataFrame.boxplot return value
Example for a local Python session
import pandas as pd
import matplotlib
frame = pd.DataFrame({"team": ["A", "A", "B"], "units": [2., 5., 7.], "price": [4., 3., 2.]})
print(frame.groupby("team").boxplot(column="units"))