I am trying to reverse an array in 2D which sounds easy but when I use np.flip or slicing method, it does not work properly. Perhaps I am doing something wrong?
import numpy as np
t = np.array([[1,2,3,4],[5,6,7,8]])
t
array([[1, 2, 3, 4],
[5, 6, 7, 8]])
t[:,::-1]
array([[4, 3, 2, 1],
[8, 7, 6, 5]])
np.flip(t, axis=1)
array([[4, 3, 2, 1],
[8, 7, 6, 5]])
np.flip(t, axis=0)
array([[5, 6, 7, 8],
[1, 2, 3, 4]])
What I want is the following:
t
array([[1, 2, 3, 4],
[8, 7, 6, 5]])
I want to reverse the elements of the 2nd dimension but keep the 1st dimension unchanged.