
Create Histogram in pandas –
Read a dataset to work with.
import pandas as pd
url = "https://raw.githubusercontent.com/bprasad26/lwd/master/data/batting.csv"
df = pd.read_csv(url)
df.head()

To create a Histogram in pandas we use the DataFrame.plot.hist() method.
df.plot.hist(y='Runs', figsize=(10,8))

If you want to change the number of bins, you can do so using the bins parameter.
df.plot.hist(y='Runs', bins=20, figsize=(10,8));

To change the color of the histogram, use the color parameter.
df.plot.hist(y='Runs', bins=20, color='seagreen', figsize=(10,8));

Comparing groups –
If you want, You can also create multiple histogram on the same figure.
fig, ax = plt.subplots(figsize=(10, 8))
indian.plot.hist(y='Runs', bins=20, color='seagreen', label='Indian', ax=ax)
overseas.plot.hist(y='Runs', bins=20, color='crimson', label='Overseas', ax=ax);

Subplots –
Instead of plotting multiple histogram on the same plot, you can plot each histogram separately in their own axes.
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(12, 7))
indian.plot.hist(y="Runs", bins=20, color="seagreen", label="Indian", ax=ax1)
overseas.plot.hist(y="Runs", bins=20, color="crimson", label="Overseas", ax=ax2)
ax1.set_xlabel("Runs")
ax2.set_xlabel("Runs")
