0

First, the result i want is this. Here is the array a.

array([[38, 44, 13,  9, 10],
       [12,  6, 16,  1, 17],
       [ 2, 13,  8, 46,  7]])

And the result comes out like this: Subtract 5 from the maximum and minimum values ​​among the elements in the axis 0.

a = [[43 49 13  9 10]
     [12  1 21 -4 22]
     [-3 13  3 51  2]]

To make this code, I first created an array a.

array_a = [[38, 44, 13, 9, 10, 12, 6, 16, 1, 17, 2, 13, 8, 46, 7]]
a = np.array(array_a).reshape(3,5)
a

And I can get the maximum and minimum values ​​using the apply_along_axis() function, but I don't know how to make an array by subtracting 5.

min_a = np.apply_along_axis(min, 0, a) 
print(min_a)
max_a = np.apply_along_axis(max, 0, a)
print(max_a)

  • Does this answer your question? [how to find minimum/maximum values axis by axis in numpy array](https://stackoverflow.com/questions/35930617/how-to-find-minimum-maximum-values-axis-by-axis-in-numpy-array) – Be Chiller Too Nov 15 '21 at 10:42
  • Thank you but I want to know how to perform a subtraction operation on the maximum & minimum values, ​​and return them as an array. – jennylui Nov 15 '21 at 10:47

0 Answers0