title: Extract specific values from array in Python
body: <p>I want to calculate means and averages in a data set, but for many reasons that I can't go into here, my array contains my values and some "filler" values (which are currently set to -1000).</p>
  
  <p>How can I calculate the mean (for example) on <b>only</b> the non -1000 values?</p>
  
  <pre><code>res=[-1000 for x in range(0,10)]
  res[1]=2
  res[5]=3
  res[7]=4
  #something like this?
  np.mean(res&gt;-1000)
  
  #the result should be the mean value of 2,3 and 4 (3)
  </code></pre>
  
  <p>MVCE</p>
  
  <pre><code>res=[1.0, 1.0, 1.0, 1.0, 1.0, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000]
  #for instance
  print(np.mean(res[res &gt; -1000]))
  </code></pre>