Reputation: 433
Suppose test = np.array(5*[np.eye(5), 10*np.eye(5), 15*np.eye(5)])
. I have three matrices inside an array with shape (3, 5, 5)
. In general, how can I reshape test
to make the three matrices into one? In that specific example, I would like the shape to be (15, 5)
. I want a general way of doing it without using some reeally specific as np.reshape(test, (15,5))
.
Upvotes: 1
Views: 114
Reputation: 12407
You can use -1 in reshape that implicitly calculates the required dimension shape:
test = test.reshape(-1, test.shape[-1])
Upvotes: 1