0

Data

a = np.array([[0.5,1,50],[0.5,1,30]])
b = np.array([[0.40,0.60],[0.75,2.0],[40,70]])

Expected results:

TRUE
FALSE

If I only had few rows, a stupid way to do it would be:

if b[0][0] <= a[0][0] <=  b[0][1] and b[1][0] <= a[0][1] <=  b[1][1] and b[2][0] <= a[0][2] <=  b[2][1]:
    print("its b!!")
1
  • How about flattening the array b, taking min and max of b; and check if the number from a lies inside [min_b, max_b]? Commented Jul 5, 2021 at 11:36

1 Answer 1

1

IIUC, here's one way:

result = np.apply_along_axis(lambda x: all((x > b.T[0]) & (x < b.T[-1])), 1, a)

OUTPUT:

array([ True, False])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.