title: Iterate over ndarray of dtype: float?
body: <p>How iterate over a select row for an array that is dtype="float"?</p>
  
  <p>Parameters x and why to pass into the function:</p>
  
  <pre><code>In [8]: x = np.array([[2000,2000,2000,0,2000,2000,2000,2000,0,2000],[1400,200,1200,1000,600,1600,800,800,1200,600],[1000,780,960,940,860,980,960,860,880,1120],[1016,982,1030,992,978,958,932,980,1040,966]])
  In [9]: print x
  [[2000 2000 2000    0 2000 2000 2000 2000    0 2000]
   [1400  200 1200 1000  600 1600  800  800 1200  600]
   [1000  780  960  940  860  980  960  860  880 1120]
   [1016  982 1030  992  978  958  932  980 1040  966]]
  
  In [10]: y = 4
  In [11]: print y
  4
  </code></pre>
  
  <p>My function: I've tried versions of this, but the real target what to iterate over in the for loop.  I tried, range(row), nditer(), etc., and I want to understand what is the best practice for iterating row by row over an ndarray? And, one step further, how to do it selectively, i.e., only row 0 and 3 when the array is dtype="float"? Currently, I get the below error.</p>
  
  <pre><code>def func(x,y):
      rows, columns = len(x), y
      daily_ret = np.zeros((rows,columns),dtype=float)
      for i in daily_ret:
          daily_ret[i] = (x[i]/1000) - 1
      print daily_ret
  </code></pre>
  
  <p>My error:</p>
  
  <pre><code>In [23]: func(x,y)
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-23-2d375b80632e&gt; in &lt;module&gt;()
  ----&gt; 1 func(x,y)
  
  &lt;ipython-input-22-e1b1d4ace166&gt; in func(x, y)
        3     daily_ret = np.zeros((rows,columns),dtype=float)
        4     for i in daily_ret:
  ----&gt; 5         daily_ret[i] = (x[i]/1000) - 1
        6     print daily_ret
  
  IndexError: arrays used as indices must be of integer (or boolean) type
  
  In [24]: k = x/1000
  </code></pre>