Jan-05-2021, 12:32 PM
Hi All
I'm wondering how to reshape the matrix A so that it equals B?
My issue is the row order; I spent a long time playing with tranpose, ravel, reshape + order, and so on, but I've not found the tock so far.
What I'm missing?
Of course using Permutation works fine in that simple example, but is there another way?
Thanks for any help
Paul
I'm wondering how to reshape the matrix A so that it equals B?
My issue is the row order; I spent a long time playing with tranpose, ravel, reshape + order, and so on, but I've not found the tock so far.
What I'm missing?
Of course using Permutation works fine in that simple example, but is there another way?
Thanks for any help
Paul
A = np.array( [[0, 0, 0, 1, 1, 1, 2, 2, 2], [1, 2, 5, 4, 7, 8, 9, 10, 11]]) #expected B = np.array( [[0, 0, 0], [1, 2, 5], [1, 1, 1], [4, 7, 8], [2, 2, 2], [9, 10, 11]]) A2 = np.reshape(A, (6, 3)) # dimension is correct but not row order Permutation = [0, 3, 1, 4, 2, 5] A3 = A2[Permutation, :] Diff = B - A3 print(Diff)