I'm attempting to convert the string '[ 0. 0. 1.]'
to a numpy array.
This is the code I've written but is more complicated that needs be ?
arr = []
s = '[ 0. 0. 1.]'
arr.append(int(s.split(" ")[1].replace("." , '')))
arr.append(int(s.split(" ")[3].replace("." , '')))
arr.append(int(s.split(" ")[5].replace("]" , '').replace("." , '')))
arr = np.array(arr)
print(arr)
print(type(arr))
print(type(arr[0]))
Above code prints :
[0 0 1]
<class 'numpy.ndarray'>
<class 'numpy.int64'>
Is there a cleaner method to convert string '[ 0. 0. 1.]' to numpy int array type ?