title: Counting the number of non-NaN elements in a numpy ndarray in Python
body: <p>I need to calculate the number of non-NaN elements in a numpy ndarray matrix. How would one efficiently do this in Python? Here is my simple code for achieving this: </p>
  
  <pre><code>import numpy as np
  
  def numberOfNonNans(data):
      count = 0
      for i in data:
          if not np.isnan(i):
              count += 1
      return count 
  </code></pre>
  
  <p>Is there a built-in function for this in numpy? Efficiency is important because I'm doing Big Data analysis. </p>
  
  <p>Thnx for any help! </p>