Reputation: 43
I have a 3d numpy array. I'd like to find the largest coordinate at each [x,y] grid point of non-zero elements along the z axis of the array. This would result in a 2d array filled with z index values. How can I do that?
Upvotes: 2
Views: 2725
Reputation: 1083
Use the amax
function in Numpy, and specify the axis along which you want the maximum to be taken:
ans = numpy.amax(arr_3D, axis=2)
Upvotes: 1