title: Python: Can't convert float NaN to integer
body: <p>I apply a moving average logic that returns float. I convert that float to int before using it to drawing line in OpenCV but getting below error</p>
  
  <pre><code>ValueError: cannot convert float NaN to integer
  </code></pre>
  
  <p>sample code</p>
  
  <pre><code>def movingAverage(avg, new_sample, N=20):
      if (avg == 0):
      return new_sample
      avg -= avg / N;
      avg += new_sample / N;
      return avg;
  
  x1 = int(avgx1) #avgx1 is returned from the movingaverage function
  y1 = int(avgy1) 
  x2 = int(avgx2)
  y2 = int(avgy2)
  cv2.line(img, (x1, y1), (x2, y2), [255,255,255], 12)
  </code></pre>
  
  <p>Any suggestion on how to solve it?</p>