Closest element to a value (Elementwise, numpy array)

Is this what you are looking for?

np.where(np.abs(a - x0) < np.abs(b - x0), a, b)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top