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)

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.