成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘

 成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: 'str' and 'int'

目录

解决问题

解决思路

解决方法


解决问题

    boxplot(array)
  File "E:\Program Files\Python\Python36\lib\site-packages\matplotlib\pyplot.py", line 2848, in boxplot
    zorder=zorder, data=data)
  File "E:\Program Files\Python\Python36\lib\site-packages\matplotlib\__init__.py", line 1855, in inner
    return func(ax, *args, **kwargs)
  File "E:\Program Files\Python\Python36\lib\site-packages\matplotlib\axes\_axes.py", line 3557, in boxplot
    labels=labels, autorange=autorange)
  File "E:\Program Files\Python\Python36\lib\site-packages\matplotlib\cbook\__init__.py", line 1841, in boxplot_stats
    stats['mean'] = np.mean(x)
  File "<__array_function__ internals>", line 6, in mean
  File "E:\Program Files\Python\Python36\lib\site-packages\numpy\core\fromnumeric.py", line 3373, in mean
    out=out, **kwargs)
  File "E:\Program Files\Python\Python36\lib\site-packages\numpy\core\_methods.py", line 172, in _mean
    ret = ret / rcount
TypeError: unsupported operand type(s) for /: 'str' and 'int'

解决思路

类型错误:不支持/:“str”和“int”的操作数类型

解决方法

通过print(array)发现,array中存在str类型数据,所以,要讲str类型数据去掉或者转为int型数据即可!

array [[2.1909676502373716 2.607015388816513 1.3860962260762568 ...
  -1.1294268713572033 2.5030404172865484 '1']
 [2.1833913365652493 2.607015388816513 1.3760805967854473 ...
  -0.7176317548954712 2.4492909440768904 '1']
 [2.172026866057066 2.607015388816513 1.3760805967854473 ...
  -0.6735108495602856 2.180543578028602 '1']
 ...
 [2.172026866057066 2.607015388816513 1.3760805967854473 ...
  -0.6735108495602856 1.9547957905480406 '1']
 [2.1833913365652493 2.607015388816513 1.3760805967854473 ...
  -0.6735108495602856 2.03004505304156 '1']
 [2.172026866057066 2.607015388816513 1.3760805967854473 ...
  -0.6735108495602856 1.9977953691157657 '1']]

哈哈,大功告成!

  • 13
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个处女座的程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值