成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘

成功解决TypeError: can't multiply sequence by non-int of type 'float'

目录

解决问题

解决思路

解决方法

1、分析bug

2、定位出错函数


扫描二维码关注公众号,回复: 14432419 查看本文章

解决问题

TypeError: can't multiply sequence by non-int of type 'float'

解决思路

类型错误:不能将序列乘以float类型的非int类型

解决方法

1、分析bug

失败运行的结果

['male' 'female' 'female' 'female' 'male' 'male' 'male' 'male' 'female'
 'female']

value_grids = np.percentile(feature_values, percentile_grids)
TypeError: can't multiply sequence by non-int of type 'float'

成功运行的结果

[1 0 0 0 1 1 1 1 0 0]

2、定位出错函数

分析函数的输入参数,分析出错参数feature,分发现该参数的规则是

feature: string or list, feature or feature list to investigate, for one-hot encoding features, feature list is required

故输入数据及数据类型,应该满足 one-hot encoding features以上条件才可以!

哈哈,大功告成!

猜你喜欢

转载自blog.csdn.net/qq_41185868/article/details/126126869
今日推荐