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>In python 2.7 dividing a numpy float by an integer will return an integer, at least that is my experience. 
As the answers say:</p>

<pre><code>In [1]: import numpy as np

In [2]: rf = np.array([ 7.11441183,  7.12383509,  7.13325787,  7.16152716,  7.17
   ...: 094994,  7.17094994,  7.18979692,  7.18979692,  7.19921923,  7.19921923,
   ...:   7.19921923,  7.19921923,  7.19921923,  7.19921923,  7.19921923,  7.208
   ...: 64296,  7.20864296,  7.20864296,  7.20864296,  7.20864296])

In [3]: print (1+rf[0:]/100)**(1/252)
[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
  1.  1.]

In [4]: print (1+rf[0:]/100.0)**(1/252.0)
[ 1.00027276  1.00027311  1.00027346  1.00027451  1.00027486  1.00027486
  1.00027556  1.00027556  1.00027591  1.00027591  1.00027591  1.00027591
  1.00027591  1.00027591  1.00027591  1.00027626  1.00027626  1.00027626
  1.00027626  1.00027626]
</code></pre>

<p>Dividing by a float solves this problem, i.e change both 100 and 252 to 100.0 and 252.0. Hope that helps.</p>

python numpy significant-digits