title: How to categorize numerical data in numpy array iteratively?
body: <p>I am currently trying to generate a numpy array with random data <code>normal = np.round(np.random.normal(loc=0.0,scale=1000,size=(size)),1).astype(int)</code>, with <code>seed = np.random.seed(0)</code> and then categorize them in an equidistant way such as:</p>
  <pre><code>d=10
  data = np.ndarray.flatten(np.asarray(normal,dtype=int))
  
  interval = np.divide(np.max(data)-np.min(data),d)
  intervals = np.arange(np.min(data),np.max(data),interval,dtype=int)
  
          for x in range(len(data)):
              for z in range(d-1):
                  if data[x] &gt;= intervals[z] and data[x] &lt; intervals[z+1]:
                      data[x] = z
                  elif data[x] &gt; intervals[-1]:
                      data[x] = d-1
  </code></pre>
  <p>Ideally when I do this, I would expect the values in my data array to be replaced by values from 0-9, but whenever I run this, I end up with values from 4-8. Anyone have an idea what I might be doing wrong or how to improve this method?</p>
  <p>Interval is the delta value to be used and Intervals are the actual boundary values for the respective intervals.</p>