Increase the significant digits in Numpy
<p>I want to know how can I increase the number of significant digits beyond the decimal.
The original "rf" numpy array contains floating point numbers.</p>

<pre><code>import numpy as np
rf=daily_rets(df)

[ 7.11441183  7.12383509  7.13325787  7.16152716  7.17094994  7.17094994  7.18979692  7.18979692  7.19921923  7.19921923  7.19921923  7.19921923  7.19921923  7.19921923  7.19921923  7.20864296  7.20864296  7.20864296  7.20864296  7.20864296]
</code></pre>

<p>But when I perform the operation I get an undesired output</p>

<pre><code>rf[0:]=(1+rf[0:]/100)**(1/252)
</code></pre>

<p>I get the following output
[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
  1.]</p>

<p>np.around() also does not help giving me the same output as above</p>

<pre><code>rf[0:]=np.around((1+rf[0:]/100)**(1/252), decimals=6)
</code></pre>

<p>I realize the above operation would make the numbers very small, still I want the numbers beyond decimals to appear</p>

<p>You could just use <a href="http://docs.scipy.org/doc/numpy/reference/ufuncs.html#available-ufuncs" rel="nofollow">numpy ufuncs</a>:</p>

<pre><code>from __future__ import division
import numpy as np
rf = np.array([7.11441183, 7.12383509, 7.13325787, 7.16152716])
np.divide(rf[0:], 100, rf[0:])
np.add(rf[0:], 1, rf[0:])
np.power(rf[0:], 1 / 252, rf[0:])

&gt;&gt;&gt; rf
array([ 1.00027276,  1.00027311,  1.00027346,  1.00027451])
&gt;&gt;&gt; 
</code></pre>

<p>Initially I thought numpy would handle the issue but as others have stated, it is the v2.7 integer division that is causing the problem.  Hopefully the ufuncs above are not too much of a distractor.</p>

python numpy significant-digits