I have a list B11
containing a list of numpy arrays. I want to convert each of these arrays into lists but I am getting an error. I also show the expected output.
import numpy as np
B11=[[np.array([353.856161, 0. , 0. ]),
np.array([ 0. , 0. , 282.754301, 0. ])],
[np.array([ 0. , 294.983702, 126.991664])]]
C11=B11.tolist()
The error is
in <module>
C11=B11.tolist()
AttributeError: 'list' object has no attribute 'tolist'
The expected output is
[[[353.856161, 0. , 0. ],[ 0. , 0. , 282.754301, 0. ]],
[ 0. , 294.983702, 126.991664]]
Copyright Notice:Content Author:「jcbose123」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74980324/converting-a-list-with-numpy-arrays-into-lists-in-python