我想在以下数据框的特定门处绘制特定月份每年“乘客”的直方图。
df=pd.DataFrame({'Year':[2005,2005,2005,2005,2006,2006,2006,2006,2007,2007,2007,2007,2008,2008,2008,2008],'Month': ['June', 'June','July', 'July','June', 'June','July', 'July','June', 'June','July', 'July','June', 'June','July', 'July'], 'Gate': ['A','B', 'A','B','A','B','A','B','A','B','A','B','A','B','A','B',], 'Passengers':[20000, 30000,25000,30000,20000, 25000, 25000,30000,30000,35000,20000,15000,20000,25000,15000,15000]})
我想要7月在A号登机口的地块:
df_month=df[df.Month=='July']
df_month_Area=df_month[df.Gate=='A']
df_month_Area=df_month_Area.groupby('Year').sum()
对于情节,我做了以下事情:
df_month_Area.plot('Year', 'Passengers', 'barh')
我收到以下错误
KeyError: 'Year'