I'm trying to find the smallest non-zero value in each row of a 2d numpy array but haven't been to find an elegant solution. I've looked at some other posts but none address the exact same problem e.g.
Minimum value in 2d array or Min/Max excluding zeros but in 1d array.
For example for the given array:
x = np.array([[3., 2., 0., 1., 6.], [8., 4., 5., 0., 6.], [0., 7., 2., 5., 0.]])
the answer would be:
[1., 4., 2.]