kiosk.csv / rain.csv.
Goal
Run every block and look at the Plot panel.
import io
csv = """city,units
Nairobi,21
Mombasa,15
Kisumu,15
"""
df = pd.read_csv(io.StringIO(csv))
plt.bar(df["city"], df["units"])
plt.title("From a CSV string")
plt.show()import io
csv = """month,mm
Jan,48
Feb,55
Mar,92
Apr,150
"""
df = pd.read_csv(io.StringIO(csv))
plt.plot(df["month"], df["mm"], marker="o")
plt.title("Rain string")
plt.show()print("Or download kiosk.csv / rain.csv and Add files.")df = pd.DataFrame({
"city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
"units": [21, 15, 15, 18, 12],
"shillings": [2100, 1500, 1480, 1750, 1190],
})
print(df.head())
plt.bar(df["city"], df["units"])
plt.show()Pitfall
Always plt.show(). Paste the whole editor.