pandas.api.typing.SeriesGroupBy.hist#
- SeriesGroupBy.hist(by=None, ax=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, figsize=None, bins=10, backend=None, legend=False, **kwargs)[source]#
Draw histogram for each group’s values using
Series.hist()API.- Parameters:
- byobject, optional
Grouping key.
- axmatplotlib.axes.Axes, optional
Axis to draw the histogram on.
- gridbool, default True
Show axis grid lines.
- xlabelsizeint, default None
X axis label size.
- xrotfloat, default None
Rotation for x ticks.
- ylabelsizeint, default None
Y axis label size.
- yrotfloat, default None
Rotation for y ticks.
- figsizetuple, optional
Figure size in inches.
- binsint or sequence, default 10
Number of histogram bins or bin edges.
- backendstr or callable or None, optional
Plotting backend to use (e.g. ‘matplotlib’). If None, use the default plotting backend.
- legendbool, default False
Whether to draw the legend.
- **kwargs
Additional keyword arguments passed to
Series.hist().
- Returns:
- matplotlib.axes.Axes or ndarray of Axes
The returned matplotlib axes or array of axes depending on input.
See also
Series.histEquivalent histogram plotting method on Series.
Examples
>>> df = pd.DataFrame({"val": [1, 2, 2, 3, 3, 3]}, index=[0, 0, 1, 1, 2, 2]) >>> g = df["val"].groupby([0, 0, 1, 1, 2, 2]) >>> g.hist()