Assume I have a list of strings and I want to convert it to the numpy array. For example I have
A=A=['[1 2 3 4 5 6 7]','[8 9 10 11 12 13 14]']
print(A)
['[1 2 3 4 5 6 7]', '[8 9 10 11 12 13 14]']
I want my output to be like the following : a matrix of 2 by 7
[1 2 3 4 5 6 7;8 9 10 11 12 13 14]
What I have tried thus far is the following:
m=len(A)
M=[]
for ii in range(m):
temp=A[ii]
temp=temp.strip('[')
temp=temp.strip(']')
M.append(temp)
print(np.asarray(M))
however my output is the following:
['1 2 3 4 5 6 7' '8 9 10 11 12 13 14']
Can anyone help me to correctly remove the left and right brackets and convert the result to the matrix of floats.