How to get the maximum and minimum elements of NumPy 2d array rows in Python

1 Answer

0 votes
import numpy as np

arr2d = np.array([[4, 8, 2,  5], 
                  [6, 9, 7,  1], 
                  [2, 0, 5, 11]])

print(np.max(arr2d, axis=1))
print(np.min(arr2d, axis=1))





'''
run:

[ 8  9 11]
[2 1 0]

'''

 



answered Mar 26, 2023 by avibootz
...