I have a simple python code:
l2 =[4,np.nan, 5.1]
a2 = np.array(l2)
a3 = np.where(np.isnan(a2), '3.3', a2)
a3 = a3.astype(float)
print(a3)
a3 = np.where(np.isnan(a2), 'x', a2)
print(a3)
The code above produce two lines:
[4. 3.3 5.1]
['4.0' 'x' '5.1']
My question is how to convert np.NaN to string, but without changes to other values.
There where was numbers should stay like number, but only there where is nan should be new string. Like that:
[4.0 'x' 5.1]