title: Looping through multiple arrays with np.where
body: <p>I have 2 lists distance_boundary and distance</p>
  
  <pre><code>distance_boundary = [100,200,300]
  distance = [125,255,285,140,160,180]
  </code></pre>
  
  <p>Now I want to create a new variable <strong>floor</strong> and I want to assign the value for floor based on the distance value and it is defined by distance_boundary</p>
  
  <p>For example , </p>
  
  <pre><code>distance[0] is 125
  </code></pre>
  
  <p>since this is between distance_boundary[0] and distance_boundary[1]
  so the corresponding value for floor should be 1</p>
  
  <pre><code>distance[1] is 255
  </code></pre>
  
  <p>since this is between distance_boundary[1] and distance_boundary[2]
  so the corresponding value for floor should be 2</p>
  
  <p>Looping through this should give me the final value of floor as </p>
  
  <pre><code>floor = [1,2,2,1,1,1]
  </code></pre>
  
  <p>I tried to loop through distance and used to np.where for assignment </p>
  
  <pre><code>floor = []
  
  for j in range(0,len(distance)):
  
      floor = (np.where((distance[j]&gt;distance_boundary[0]) &amp; (distance[j]&gt;distance_boundary[1]))
                        ,1,2)
      floor.append(floor)
  </code></pre>
  
  <p>This is not giving me desired result and moreover it is not looking scalable. 
  Is there any other better solution</p>