If I have a numpy array, how do I convert so that the value of each element is zero, except for the max element of each row, which should be 1, without a brute-force looping solution? For example, given:
array([[1, 2, 3, 4],
[2, 3, 4, 1],
[3, 4, 1, 2],
[4, 1, 2, 3]])
How do I produce:
array([[0,0,0,1],
[0,0,1,0],
[0,1,0,0],
[1,0,0,0]])
Note: For my actual case, I won't know the actual values in the array. All I will know is that the values are non-negative.