df.plot(..., kind="hist").
Goal
Draw this kind four ways.
df = pd.DataFrame({
"city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
"units": [21, 15, 15, 18, 12],
"shillings": [2100, 1500, 1480, 1750, 1190],
})
df.plot(y="units", kind="hist")
plt.title("hist")
plt.show()rng = np.random.default_rng(0)
s = pd.Series(rng.integers(1, 20, size=80), name="units")
s.plot(kind="hist", bins=8)
plt.title("hist")
plt.show()df = pd.DataFrame({
"city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
"units": [21, 15, 15, 18, 12],
"shillings": [2100, 1500, 1480, 1750, 1190],
})
print(df.head())
df.plot(x="city", y="shillings", kind="hist")
plt.show()print("kind=hist")