I have a string representation of a numpy array of arrays. How do you convert from this format to an array of arrays?
Asked
Active
Viewed 229 times
0
-
Does this answer your question? [Convert a String representation of a Dictionary to a dictionary?](https://stackoverflow.com/questions/988228/convert-a-string-representation-of-a-dictionary-to-a-dictionary) – RichieV Sep 01 '20 at 00:07
-
That's a vague description of your string. How did you create this string? You know, don't you, the normal way of creating an array from a list of lists? – hpaulj Sep 01 '20 at 00:24
1 Answers
0
Using eval is the best solution
import numpy as np
a = "np.array([[1,2],[2,3]])"
a = eval(a)

hxalchemy
- 366
- 1
- 10