5

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.

cs95
  • 379,657
  • 97
  • 704
  • 746
yasuomain
  • 55
  • 1
  • 1
  • 5
  • Please see if [this](https://matplotlib.org/examples/api/barchart_demo.html) is helpful. –  Nov 16 '17 at 21:36

2 Answers2

2

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()

enter image description here

If you're interested in annotating the bars too, take a look at Annotate bars with values on Pandas bar plots.

cs95
  • 379,657
  • 97
  • 704
  • 746
2

You can also do this without set_index()

df.plot.bar(x = 'Tour', y = ['Start', 'End'])

enter image description here

Vaishali
  • 37,545
  • 5
  • 58
  • 86