Oct-25-2020, 07:42 AM
Hi everyone,
I would appreciate some tips regarding my problem. There is an array (np.array) where I should find rows and columns of interesting elements. The array has values between 0 and 360
Example:
[20 20 33 360]
[54 62 27 89]
[120 200 300 54]
Now this works: r, c = np.where(array <20)
This does not: r, c = np.where(340 < array < 20) or np.where(array > 340 | array < 20 ) or np.where(array > 340 or array < 20 )
This also does not work: x = (array > 340) | array(array < 20)
Error I get is ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
What would be the best way to find rows and columns of elements for which multiple conditions have to be checked. Of course I could write r, c for every condition separately using np.where but that would be to many lines.
Any tips would be appreciated
I would appreciate some tips regarding my problem. There is an array (np.array) where I should find rows and columns of interesting elements. The array has values between 0 and 360
Example:
[20 20 33 360]
[54 62 27 89]
[120 200 300 54]
Now this works: r, c = np.where(array <20)
This does not: r, c = np.where(340 < array < 20) or np.where(array > 340 | array < 20 ) or np.where(array > 340 or array < 20 )
This also does not work: x = (array > 340) | array(array < 20)
Error I get is ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
What would be the best way to find rows and columns of elements for which multiple conditions have to be checked. Of course I could write r, c for every condition separately using np.where but that would be to many lines.
Any tips would be appreciated