pandas.DataFrame.hist
pandas 3.1.1 · DataFrame · method
Draw histograms to show how numeric observations are distributed across bins.
Call syntax
DataFrame.hist(…) Full signature
DataFrame.hist(
data,
column=None,
by=None,
grid=True,
xlabelsize=None,
xrot=None,
ylabelsize=None,
yrot=None,
ax=None,
sharex=False,
sharey=False,
figsize=None,
layout=None,
bins=10,
backend=None,
legend=False,
**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 |
|---|---|---|
data |
Required Positional or keyword |
DataFrame Provide the input data read, transformed, or stored by this call. |
column |
Optional Positional or keyword Default None |
str or sequence Identify the column or columns to use. |
by |
Optional Positional or keyword Default None |
object Specify the labels, mapping, or values that determine the sort or grouping. |
grid |
Optional Positional or keyword Default True |
bool Choose whether the plot displays grid lines. |
xlabelsize |
Optional Positional or keyword Default None |
int Set the size of horizontal-axis tick labels. |
xrot |
Optional Positional or keyword Default None |
float |
ylabelsize |
Optional Positional or keyword Default None |
int Set the size of vertical-axis tick labels. |
yrot |
Optional Positional or keyword Default None |
float |
ax |
Optional Positional or keyword Default None |
Matplotlib axes object Provide the existing Matplotlib axes on which to draw. |
sharex |
Optional Positional or keyword Default False |
bool Choose whether subplots share their horizontal axis. |
sharey |
Optional Positional or keyword Default False |
bool Choose whether subplots share their vertical axis. |
figsize |
Optional Positional or keyword Default None |
tuple Set the figure width and height as a pair, in inches. |
layout |
Optional Positional or keyword Default None |
tuple Set the subplot grid shape as a pair of dimensions. |
bins |
Optional Positional or keyword Default 10 |
int or sequence Set a number of bins or provide bin boundaries. |
backend |
Optional Positional or keyword Default None |
str |
legend |
Optional Positional or keyword Default False |
bool Choose whether to display a legend. |
**kwargs |
Optional Additional keyword arguments |
Returns
np.ndarray
Example for a local Python session
import pandas as pd
import matplotlib
frame = pd.DataFrame({"units": [2., 5., 7.], "price": [4., 3., 2.]})
print(frame.hist(column="units"))