Numpy

Numpy (19)

Jun's N 2022. 8. 10. 22:03

How to reverse the columns of a 2D array?

# Input
arr = np.arange(9).reshape(3,3)

# Solution
arr[:, ::-1]

# output
array([[2, 1, 0],
       [5, 4, 3],
       [8, 7, 6]])
728x90