NaN keyed dictionaries for pandas series
I am trying to build a Pandas series by passing it a dictionary containing index and data pairs. In doing so, I noticed an interesting quirk. When a dictionary contains NaN keys with an associated value, Pandas Series stores the NaN key in the index, but also sets the corresponding NaN value.
import pandas as pd d = {np.nan: 3500.0, 66485174.0: 1.0} d = pd.Series(d, dtype='float64')
In the above example 3500.0 will be set to NaN using pd.Series. I am using Pandas 0.20.2 with python 2.7.
Does anyone know why this is happening? My intuition is that NaN is probably treated as an infinite number outside of 64-bit, so format issues may arise
+3
source to share
No one has answered this question yet
Check out similar questions: