Issue
I have the below numpy array
[[7, 0, 0, 6],
[5, 6, 6, 1],
[4, 1, 6, 7],
[5, 3, 4, 7]]
I want to find the max no in each column using np.max and then print out the result in an object such that output will be as shown below
[7, 6, 6, 7]
Solution
If arr
is your array, then you just need to use the max
function, indicating the chosen axis:
arr.max(axis=0)
Output:
array([7, 6, 6, 7])
If you want a list instead of a numpy array:
arr.max(axis=0).tolist()
Output:
[7, 6, 6, 7]
Answered By - Riccardo Bucco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.