这个错误真的tmd伤脑筋。我用idxmax函数去求series类型的最大值的索引,结果明明是下面这种数据,

TypeError: reduction operation 'argmax' not allowed for this dtype

无论我如何pint他的shape,type,他怎么看都是一个满足idxmax函数要求的参数类型:标准的Series类型,且每个元素都是浮点数,

但是

TypeError: reduction operation 'argmax' not allowed for this dtype

 

然鹅,当我最后在调试中看到了一个不起眼的地方

TypeError: reduction operation 'argmax' not allowed for this dtype

这个貌似元素为浮点数的Series变量,啥时候元素类型成了object,我不得而知,也不想知道,我只知道,我需要加上一行美丽的代码

results_table['Mean_recall_score'] = results_table['Mean_recall_score'].astype('float64')

以及以后一定一定要注意DataFram中的元素类型

相关文章: