我正在尝试创建条形柱状图,以按组显示主题的平均值我的数据看起来像这样- week 8 exp Subject Group 1 2 3 Mean0 255 WT 0 101.8 75.6 84.1 87.1666671 157 HD 0 92.6 87.8 82.3 87.5666672 418 WT 0 54.5 47.0 50.8 50.7666673 300 WT 0 48.1 73.1 72.2 64.4666674 299 HD 0 71.8 86.0 93.4 83.7333335 258 WT 0 88.0 98.5 50.2 78.9000006 173 WT 0 75.4 70.5 83.9 76.6000007 273 HD 0 103.6 94.2 108.3 102.0333338 175 WT 0 36.7 30.7 42.2 36.5333339 172 HD 0 82.6 91.6 73.4 82.53333310 263 WT 0 110.7 102.4 105.5 106.20000011 304 1 90.4 90.1 103.4 94.63333312 305 1 128.6 141.5 123.1 131.06666713 306 1 52.0 45.6 57.2 51.60000014 309 0.1 41.3 52.6 79.9 57.93333315 317 0.1 86.2 95.8 77.1 86.366667我的代码是-frame_data = pd.read_csv('final results.csv', header=[0,1])data_avg = df.iloc[:, -3:].mean(axis=1)frame_data[('exp', 'Mean')] = frame_data.iloc[:, -3:].mean(axis=1)grouped_by_group = frame_data.groupby(['Group', 'Mean']).size().unstack('Mean')grouped_by_group.plot.bar(title='Grip')我收到一个错误KeyError:“组”我检查了很多次,这是它写的方式...我不知道这是怎么回事...
添加回答
举报
0/150
提交
取消