As in this question that shows how using nan from numpy causes problems with a dict, why does math.nan behave differently? (Python3)
import math
import numpy as np
d = {math.nan:'baz', math.nan:'bip' }
print(d)
e = {np.float('nan'):'foo', np.float('nan'):'bar' }
print(e)
Output
{nan: 'bip'}
{nan: 'foo', nan: 'bar'}