df.plot(..., kind="bar").
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(x="city", y="units", kind="bar")
plt.title("bar")
plt.show()df = pd.DataFrame({
"city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
"units": [21, 15, 15, 18, 12],
"shillings": [2100, 1500, 1480, 1750, 1190],
})
df.plot(x="city", y="units", kind="bar", color="#1d4f7a")
plt.title("styled")
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="bar")
plt.show()print("kind=bar")