Although I have tried np.reshape and transpose, I am not getting the desired output.
I have a numpy array that looks like this:
>>> a = np.array([[1, 1, 2, 2],[1, 1, 2, 2],[1, 1, 2,2]])
>>> a
array([[1, 1, 2, 2],
[1, 1, 2, 2],
[1, 1, 2, 2]])
I want the following:
>>> b = np.array([[1, 2],[1,2],[1,2],[1, 2],[1,2],[1,2]])
>>> b
array([[1, 2],
[1, 2],
[1, 2],
[1, 2],
[1, 2],
[1, 2]])
The best I can do is in four lines of code:
e, f = np.hsplit(a,2)
e = e.reshape(np.size(e))
f = f.reshape(np.size(f))
b = np.vstack((e,f)).T
Can someone provide me with the pythonic way to reshape an array in this manner?
b = np.reshape(a,(6,2),'F')be enough?