I have a numpy array where each element looks something like this:
['3' '1' '35' '0' '0' '8.05' '2']
['3' '1' '' '0' '0' '8.4583' '0']
['1' '1' '54' '0' '0' '51.8625' '2']
I would like to replace all empty strings like the ones in the second row above, with some default value like 0. How can I do this with numpy?
The ultimate goal is to be able to run this: S.astype(np.float)
, but I suspect the empty strings are causing problems in the conversion.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…