yas*_*ain 5 python plot pandas
旅游 = 旅游名称
开始 = 开始时的可用预订
结束 = 剩余预订量
.csv 文件列:
ID | Tour | Start | End
12345 | Italy | 100 | 80
13579 | China | 50 | 30
24680 | France | 50 | 30
Run Code Online (Sandbox Code Playgroud)
到目前为止我有这个
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
Run Code Online (Sandbox Code Playgroud)
我想用给定的数据制作一个看起来像这样的条形图。
IIUC,致电set_index并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()
Run Code Online (Sandbox Code Playgroud)
如果您也对注释条形感兴趣,请查看使用Pandas 条形图上的值注释条形。