Why Does This Array Has No Attribute 'log10'?
I'm trying to calculate the log10 of an ndarray, but I'm getting the following error: AttributeError: 'float' object has no attribute 'log10', by doing some research I found that i
Solution 1:
The data type of hx
is object
. You can see that in the output, and you can check hx.dtype
. The objects stored in the array are apparently Python floats. Numpy doesn't know what you might have stored in a object array, so it attempts to dispatch its functions (such as log10
) to the objects in the array. This fails because Python floats don't have a log10
method.
Try this at the beginning of your code:
hx = hx.astype(np.float64)
Post a Comment for "Why Does This Array Has No Attribute 'log10'?"