I have a dict of strings (stored as arrays) and I'd like to convert them back to their original type. Why? I'm reading and writing a json file and need to convert them back into arrays after reading it back from file.
"KdBP": "[13, 31]",
"KdV": "[0.001, 0.002]",
"KiBP": "[13, 31]",
"KiV": "[0.01, 0.02]",
"KpBP": "[13, 31]",
"KpV": "[0.175, 0.225]"
}
b = np.asarray(a["KdBP"])
print(b)```
=====
```[13, 31]```
As expected!
====
```print(b[0])```
```IndexError: too many indices for array```
What?!
====
```b = np.asarray(a["KdBP"])
print(b)
c = np.asarray(a["KdV"])
print(c)
d = b,c```
====
```[13, 31]
[0.001, 0.002]
(array('[13, 31]', dtype='<U8'), array('[0.001, 0.002]', dtype='<U14'))```
What the heck? What's this extra (array('... garbage?
All I'm trying to do is convert the string "[13.25, 31.21]" to an indexable array of floats --> [13.25, 31.21]