Tour = Tour Name
Start = Available reservations at the start
End = Amount of reservations left
csv file columns:
ID | Tour | Start | End
12345 | Italy | 100 | 80
13579 | China | 50 | 30
24680 | France | 50 | 30
I have this so far
import pandas as pd
df = pd.read_csv("items4.csv",sep=",").set_index('ID')
d = dict(zip(df.index,df.values.tolist()))
print(d)
{12345: ['Italy', 100, 80], 13579: ['China', 50, 30], 24680: ['France', 50, 30]} #This is the output
I want to make a bar chart that looks something like this with this given data.
IIUC, call set_index
and plot.bar
:
df
ID Tour Start End
0 12345 Italy 100 80
1 13579 China 50 30
2 24680 France 50 30
df.set_index('Tour')[['Start', 'End']].plot.bar()
plt.show()
If you're interested in annotating the bars too, take a look at Annotate bars with values on Pandas bar plots.
You can also do this without set_index()
df.plot.bar(x = 'Tour', y = ['Start', 'End'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With