pandas 1.4.2

ParametersReturns
box(self, by=None, **kwargs)

A box plot is a method for graphically depicting groups of numerical data through their quartiles. The box extends from the Q1 to Q3 quartile values of the data, with a line at the median (Q2). The whiskers extend from the edges of box to show the range of the data. The position of the whiskers is set by default to 1.5*IQR (IQR = Q3 - Q1) from the edges of the box. Outlier points are those past the end of the whiskers.

For further details see Wikipedia's entry for boxplot.

A consideration when using this chart is that the box and the whiskers can overlap, which is very common when plotting small sets of data.

Parameters

by : str or sequence

Column in the DataFrame to group by.

versionchanged

Previously, :None:None:`by` is silently ignore and makes no groupings

**kwargs :

Additional keywords are documented in DataFrame.plot .

Returns

:class:`matplotlib.axes.Axes` or numpy.ndarray of them

Make a box plot of the DataFrame columns.

See Also

DataFrame.boxplot

Another method to draw a box plot.

Series.plot.box

Draw a box plot from a Series object.

matplotlib.pyplot.boxplot

Draw a box plot in matplotlib.

Examples

Draw a box plot from a DataFrame with four columns of randomly generated data.

.. plot:: 
    ('context', 'close-figs')
    
>>> data = np.random.randn(25, 4)
>>> df = pd.DataFrame(data, columns=list('ABCD'))
>>> ax = df.plot.box()

You can also generate groupings if you specify the :None:None:`by` parameter (which can take a column name, or a list or tuple of column names):

versionchanged
.. plot:: 
    ('context', 'close-figs')
    
>>> age_list = [8, 10, 12, 14, 72, 74, 76, 78, 20, 25, 30, 35, 60, 85]
>>> df = pd.DataFrame({"gender": list("MMMMMMMMFFFFFF"), "age": age_list})
>>> ax = df.plot.box(column="age", by="gender", figsize=(10, 8))
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/plotting/_core.py#1219
type: <class 'function'>
Commit: