exploring the Internet doesn't give me any results with my problem. I have array like this:
y= [[ 2.63321579e-16 9.99986649e-01 2.90973702e-32 9.93230242e-06
1.56965105e-30 1.63843623e-07 8.52455060e-22 0.00000000e+00
5.65191413e-27 0.00000000e+00 3.20573202e-25 0.00000000e+00
3.33013941e-06 0.00000000e+00 8.01929339e-22 2.14279644e-26
0.00000000e+00 4.32979661e-08 1.01565330e-29 0.00000000e+00
0.00000000e+00 4.52104604e-11]
[ 0.00000000e+00 1.57162935e-01 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 8.42837036e-01 3.78666698e-08 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00 0.00000000e+00]]
what I would like to do is replacing the second maximum value for each row with '1' and any other values there with '0'. I know how to this with max value, firstly creating zeros_like array and than replacing max value there with 1. So for this the method is:
x = np.zeros_like(y)
x[np.arange(len(y)), y.argmax(1)] = 1
but how would it be with the second max value? Desired output should be like:
y= [[ 0 0 0 **1** 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[ 0 **1** 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
I can get the second max value, but replacing it causes my problem.