tml)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.plot.hist  #

DataFrame.plot.  hist  (  _ by  =  None  _ , _ bins  =  10  _ , _ **  kwargs
_ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/plotting/_core.py#L1349-L1409) #

    

Draw one histogram of the DataFrameâs columns.

A histogram is a representation of the distribution of data. This function
groups the values of all given Series in the DataFrame into bins and draws all
bins in one [ ` matplotlib.axes.Axes  `
](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes
"\(in Matplotlib v3.8.4\)") . This is useful when the DataFrameâs Series are
in a similar scale.

Parameters  :

    

**by** str or sequence, optional

    

Column in the DataFrame to group by.

Changed in version 1.4.0:  Previously,  by  is silently ignore and makes no
groupings

**bins** int, default 10

    

Number of histogram bins to be used.

****kwargs**

    

Additional keyword arguments are documented in [ ` DataFrame.plot()  `
](pandas.DataFrame.plot.html#pandas.DataFrame.plot "pandas.DataFrame.plot") .

Returns  :

    

class:  matplotlib.AxesSubplot

    

Return a histogram plot.

See also

[ ` DataFrame.hist  ` ](pandas.DataFrame.hist.html#pandas.DataFrame.hist
"pandas.DataFrame.hist")

    

Draw histograms per DataFrameâs Series.

[ ` Series.hist  ` ](pandas.Series.hist.html#pandas.Series.hist
"pandas.Series.hist")

    

Draw a histogram with Seriesâ data.

Examples

When we roll a die 6000 times, we expect to get each value around 1000 times.
But when we roll two dice and sum the result, the distribution is going to be
quite different. A histogram illustrates those distributions.

    
    
    >>> df = pd.DataFrame(np.random.randint(1, 7, 6000), columns=['one'])
    >>> df['two'] = df['one'] + np.random.randint(1, 7, 6000)
    >>> ax = df.plot.hist(bins=12, alpha=0.5)
    

![../../_images/pandas-DataFrame-plot-hist-1.png](../../_images/pandas-
DataFrame-plot-hist-1.png)

A grouped histogram can be generated by providing the parameter  by  (which
can be a column name, or a list of column names):

    
    
    >>> 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.hist(column=["age"], by="gender", figsize=(10, 8))
    

![../../_images/pandas-DataFrame-plot-hist-2.png](../../_images/pandas-
DataFrame-plot-hist-2.png)

[ __ previous  pandas.DataFrame.plot.hexbin
](pandas.DataFrame.plot.hexbin.html "previous page") [ next
pandas.DataFrame.plot.kde  __ ](pandas.DataFrame.plot.kde.html "next page")

__ On this page

  * ` DataFrame.plot.hist()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.plot.hist.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.