df.plot(..., kind="scatter").
Goal
Draw this kind four ways.
df = pd.DataFrame({
"units": [12, 7, 9, 4, 11, 3, 14, 8],
"shillings": [1260, 1540, 945, 880, 1155, 660, 1470, 1760],
"city": ["Nairobi", "Nairobi", "Mombasa", "Mombasa", "Kisumu", "Kisumu", "Nakuru", "Eldoret"],
})
df.plot(x="units", y="shillings", kind="scatter")
plt.title("scatter")
plt.show()df = pd.DataFrame({
"units": [12, 7, 9, 4, 11, 3, 14, 8],
"shillings": [1260, 1540, 945, 880, 1155, 660, 1470, 1760],
"city": ["Nairobi", "Nairobi", "Mombasa", "Mombasa", "Kisumu", "Kisumu", "Nakuru", "Eldoret"],
})
df.plot(x="units", y="shillings", kind="scatter")
plt.title("scatter")
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="scatter")
plt.show()print("kind=scatter")