w3resource

Pandas DataFrame: hist() function

DataFrame.hist() function

The hist() function is used to make a histogram of the DataFrame’s

A histogram is a representation of the distribution of data. This function calls matplotlib.pyplot.hist(), on each series in the DataFrame, resulting in one histogram per column.

Syntax:

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, **kwds)

Parameters:

Name Description Type/Default Value Required / Optional
data The pandas object holding the data. DataFrame Required
column  If passed, will be used to limit data to a subset of columns. string or sequence Required
by If passed, then used to form histograms for separate groups. object Optional
grid Whether to show axis grid lines. bool
Default Value: True
Required
xlabelsize If specified changes the x-axis label size. int
Default Value: None
Required
xrot Rotation of x axis labels. For example, a value of 90 displays the x labels rotated 90 degrees clockwise. float
Default Value: None
Optional
ylabelsize If specified changes the y-axis label size. int
Default Value: None’
Required
yrot Rotation of y axis labels. For example, a value of 90 displays the y labels rotated 90 degrees clockwise. float
Default Value: None
Required
ax The axes to plot the histogram on. Matplotlib axes object
Default Value: ‘axes’
Required
sharex In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in. Note that passing in both an ax and sharex=True will alter all x axis labels for all subplots in a figure. bool
Default Value: True if ax is None else False
Required
sharey In case subplots=True, share y axis and set some y axis labels to invisible. bool
Default Value: False
Required
figsize The size in inches of the figure to create. Uses the value in matplotlib.rcParams by default. tuple Required
layout Tuple of (rows, columns) for the layout of the histograms. tuple optional
bins Number of histogram bins to be used. If an integer is given, bins + 1 bin edges are calculated and returned. If bins is a sequence, gives bin edges, including left edge of first bin and right edge of last bin. In this case, bins is returned unmodified. integer or sequence
Default Value: 10
Required
**kwds All other plotting keyword arguments to be passed to matplotlib.pyplot.hist().   Required

Returns: matplotlib.AxesSubplot or numpy.ndarray of them

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame.boxplot() function
Next: DataFrame - sparse.from_spmatrix() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/pandas/dataframe/dataframe-hist.php