2017-11-16 8 views
3

ツアー=ツアー名このCSVデータを棒グラフに変換するにはどうすればよいですか?

スタート=利用可能な予約開始時に予約の

終了=金額は

CSVファイルの列を左:

ID  | Tour | Start | End 

12345 | Italy | 100 | 80 

13579 | China | 50 | 30 

24680 | France | 50 | 30 

は、私がこれまでに

これを持っています
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 

私はバーを作りたいこの与えられたデータでthisのようなものになっています。

+0

場合は、[この](https://matplotlib.org/examples/api/barchart_demo.html)を参照してくださいに便利です。 –

答えて

1

IIUC、​​と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

Annotate bars with values on Pandas bar plotsを見てみましょう。

1

あなたはまた、set_indexせずにこれを行うことができます()

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

enter image description here

関連する問題