unsupported operand type(s) for -: 'str' and 'float'

qq_36728692 2018-12-27 10:34:52
plt.figure(figsize = (8, 8))

# Graph the age bins and the average of the target as a bar plot
plt.bar(age_groups.index.astype(str), 100 * age_groups['TARGET']) (需要改的代码行)

# Plot labeling
plt.xticks(rotation = 75); plt.xlabel('Age Group (years)'); plt.ylabel('Failure to Repay (%)')
plt.title('Failure to Repay by Age Group');

系统报错是:unsupported operand type(s) for -: 'str' and 'float'

而我想的到的效果是:


不知道该如何更正TAT
...全文
3533 回复 打赏 收藏 举报
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复
发帖
脚本语言

3.7w+

社区成员

JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • ITBOB • 鲍勃
加入社区
帖子事件
创建了帖子
2018-12-27 10:34