title: How to map NaN in numpy to values using dictionary?
body: <p>I have a dictionary that maps numeric values to labels. I use it to create labels for a given numpy array. The array initially contains all NaN values and some elements get populated with non-NaN values. I want to map NaN values to a label. However, this fails:</p>
  
  <pre><code>import numpy as np
  # make array with all NaNs
  a = np.ones(5) * np.nan
  # populate some of it with non-NaN values
  a[0] = 1
  a[1] = 2
  l = {"1": "one", 2: "two", np.nan: "NA"}
  for k in l:
    if k == np.nan:
      print l[k]
  # this returns false
  print (np.nan in a)
  </code></pre>
  
  <p>Is this because of the initialization of the array? Why is <code>np.nan</code> not equal to the NaN values in <code>a</code>?</p>
  
  <p>I am trying to get a working version of:</p>
  
  <pre><code>print l[a[3]]  # should print "NA", not raise keyerror
  </code></pre>