I have an array A of shape (30,) where each row has a list with 2000 elements. I want to convert this into a 2d array of shape (30, 2000). This is what I tried
A = np.reshape(A, (30, -1))
But, running this gives me an array of shape (30, 1) rather than (30, 2000). What should I do to get the correct shape?
>Solution :
where each row has a list with 2000 elements
As Ahmed Mohamed AEK points out in the comments this won’t work as the numpy object is of shape (30,). One easy fix is to stack them into a 30 by 2000 np.array.
For example:
A = np.vstack(A)
or equvalently:
A = np.stack(A, axis=0)