title: Inconsistent behavior of nans in Python numpy / pandas
body: <p>When I was working on some set operations in Python, using <code>numpy</code> and <code>pandas</code> I came across a strange phenomenon, which, I would state, results in an inconsistency in <code>nan</code>s handling.</p>
  
  <p>Let's assume that we have a very simple situation with sets as our points of interest:</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  
  a = {1, 2, 3, np.nan}
  b = {1, 2, 4, np.nan}
  
  print(a - b)
  </code></pre>
  
  <p>Out:</p>
  
  <pre><code>{3}
  </code></pre>
  
  <p>This is perfectly fine and we would expect it to be so, but let us continue with somewhat more complicated example, where <code>pandas</code> series / data frame is included:</p>
  
  <pre><code>series = pd.Series([1, 2, 3, np.nan, 1, 2, 3])
  d = set(series)
  print(d)
  </code></pre>
  
  <p>Out:</p>
  
  <pre><code>{nan, 1.0, 2.0, 3.0}
  </code></pre>
  
  <p>Once again, perfectly fine. Though, when we call:</p>
  
  <pre><code>print(d - b)  # the same applies to a single column of a data frame in place of a series
  </code></pre>
  
  <p>the result is (quite unexpectedly to me):</p>
  
  <pre><code>{nan, 3.0}
  </code></pre>
  
  <p>There is still a <code>nan</code> value in the output.</p>
  
  <p>I do understand that when we create the <code>series</code> variable all of the input values are cast under the hood to a <code>float64</code> format, including the <code>nan</code> value.</p>
  
  <pre><code>type(series.iloc[3])
  </code></pre>
  
  <p>Out:</p>
  
  <pre><code>numpy.float64
  </code></pre>
  
  <p>Whereas the type of a freely created <code>np.nan</code> is just <code>float</code>. Of course, the <code>np.isnan()</code> function in both cases returns <code>True</code>. I still see it though as an inconsistency, because I would assume that all basic Python operations (to which set operations undoubtedly belong) will be treating <code>nan</code>s in a similar manner to the numbers. Even if the same type conversion as in case of <code>nan</code>s was applied to the numbers in the sets (in pure Python they are <code>int</code>s, whereas in <code>pandas</code> series they are <code>float</code>s), set operations still consider them as the same entities and remove values adequately. <code>nan</code> is supposed to be also (quasi-)numeric and yet is handled differently. Is this a feature, a bug or an acknowledged situation which cannot be for some reason resolved?</p>
  
  <p>Python version: 3.6.6.
  Numpy version: 1.16.2.
  Pandas version: 0.24.2.</p>