I am having trouble converting a python list-of-list-of-list to a 3 dimensional numpy array.
a = [
[
[1,2,3,4], # = len 4
...
], # = len 58
...
] # = len 1245
when I call a = np.array(a)
on it, it reports shape as (1245,)
and I cannot reshape it. a.reshape(1245,58,4)
It gives me the error:
ValueError: cannot reshape array of size 1245 into shape (1245,58,4)
But If I print a[0] it gives me a 58 element list and a[0][0] gives me a 4 element list, as I expected, so the data is there.
I see plenty of stack exchange posts wanting to flatten it, but I just want to make it into a numpy array in the shape that it already is. I don't know why numpy.array()
is not seeing the other dimensions.