Lets say I have the array:
x = np.array([0.00001,0.001])
numpy will make the numbers to
array([ 1.00000000e-05, 1.00000000e-03])
Now I want to get the exponents, something like
x.get_exponent()
with result
[-5,-3]
You can use np.floor(np.log10(np.abs(x)))
.
For example:
In [13]: x = np.array([0.00001, -0.001, 0.0000025, 0.09, -13.25, 9876.5])
In [14]: x
Out[14]:
array([ 1.00000000e-05, -1.00000000e-03, 2.50000000e-06,
9.00000000e-02, -1.32500000e+01, 9.87650000e+03])
In [15]: np.floor(np.log10(np.abs(x))).astype(int)
Out[15]: array([-5, -3, -6, -2, 1, 3])
Use log10
In [49]: x = np.array([0.00001,0.001])
In [50]: np.log10(x)
Out[50]: array([-5., -3.])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With