Example problem:
import numpy as np
dc = dict()
dc[np.float(\'nan\')] = 100
dc[np.float(\'nan\')] = 200
It is creating multiple entries for
For historical reasons explained here,
np.float('nan') == np.float('nan')
is False. The rule is just that you can't have two dictionary keys which are equal to each other - so you can have two keys equal to np.float('nan')
.
Of course, this behavior is counterintuitive and surprising - so you should avoid using np.float('nan')
as a key.