【python报错】‘float‘ object has no attribute ‘log‘ / loop of ufunc does not support argument 0 of type

报错情况:

原来的对数转换(如下),前面调过一些数后就报错。

np.log(data['Item']+1)

在这里插入图片描述

AttributeError Traceback (most recent call last)
AttributeError: ‘float’ object has no attribute ‘log’

TypeError: loop of ufunc does not support argument 0 of type float which has no callable log method

解决方法

np.log(data['Item']+1)

改成

np.log((data['Item']+1).astype('float'))

你可能感兴趣的:(Python,解决各种疑难杂症,python,bug)