I have a string like that:
'[[-1. ]
[ 4.5]
[ 0. ]]
[[ 8.]
[ 0.]
[ 6.]]
[[ 0. ]
[ 4. ]
[ 0.66666667]]'
and I want to convert into a NumPy array like this
array([[[-1. ],
[ 4.5 ],
[ 0. ]],
[[ 8. ],
[ 0. ],
[ 6. ]],
[[ 0. ],
[ 4. ],
[ 0.66666667]]])
i try this code but didn't gat my answer
np.array(list(string.replace(']','],')))
# Remove all white spaces while string.find(" ") != -1: string = string.replace(" ", "") # Add comma between brackets string = string.replace("][", "],[")Then you will need to convert it into a list object where each element is a string you can convert into an int.