How to reverse numpy 2D array (matrix) values in rows in Python

1 Answer

0 votes
import numpy as np

arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
arr = np.flip(arr, axis=1)

print(arr)
                  
                  

'''
run:

[[ 4  3  2  1]
 [ 8  7  6  5]
 [12 11 10  9]]

'''

 



answered Feb 22, 2023 by avibootz

Related questions

...