Why not use numpy for this?
>>> values = np.array([3, 5, 0, 3, 5, 1, 4, 0, 9], dtype=np.double)
>>> values[ values==0 ] = np.nan
>>> values
array([ 3., 5., nan, 3., 5., 1., 4., nan, 9.])
It should be noted that values cannot be an integer type array.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…