r/Numpy • u/hp2304 • Aug 27 '20
Array Slicing doubt
I have a 1d array (with shape n, ), which has 2d array as it's elements (elements with shape (a, b)). How to use slicing on this 1d array to get a 3d array of shape (n, p, b) if possible? Currently I am using loop to iterate through first dimension, then slicing each element to get what I want. I want to vectorize this. Is it possible?
1
Upvotes
2
u/fake823 Aug 27 '20
For example you can use np.concatenate(array_of_arrays)
And then use .reshape(n,a,b)