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

tech2026-06-20  4

报错情况:

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

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'))
最新回复(0)