title: Replace the zeros in a NumPy integer array with nan
body: <p>I wrote a python script below:</p>
  
  <pre><code>import numpy as np
  
  arr = np.arange(6).reshape(2, 3)
  arr[arr==0]=['nan']
  print arr
  </code></pre>
  
  <p>But I got this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Desktop\test.py", line 4, in &lt;module&gt;
      arr[arr==0]=['nan']
  ValueError: invalid literal for long() with base 10: 'nan'
  [Finished in 0.2s with exit code 1]
  </code></pre>
  
  <p>How to replace zeros in a NumPy array with nan?</p>