I am running python 3.5 and trying to convert a large string of strings into a numpy array.
I used the answer from stack overflow to put this code together.
import ast
import numpy as np
str = '["8.4","4.3E-7"]'
arr = ast.literal_eval(str)
x = np.array(arr, dtype='|S4')
y = x.astype(np.float32)
I am getting the folllowing value error
ValueError: could not convert string to float: '4.3E'
str is an example string , most of the numbers don't have E-something pattern, but occasionally this happens and my code hangs up.
is there a way to convert string to numpy array in this case?