Issue
I have a 2d nummpy array something like this:
(array([[7.948829 , 3.7127783, 3.6365926, 3.4607997]], dtype=float32),
array([[ 5, 15, 7, 39]]))
The first array in this array are distances and the second is indices, I want to know if there is a way I could filter the first array based on a certain threshold and then also delete the corresponding indices from the index?
Solution
you mean like this?
import numpy as np
a = np.array([7.948829 , 3.7127783, 3.6365926, 3.4607997])
b = np.array([ 5, 15, 7, 39])
c = b[a>3.7]
d = a[a>3.7]
print(f'c = \n{c}')
print(f'd = \n{d}')
output:
c =
[ 5 15]
d =
[7.948829 3.7127783]
Answered By - yann ziselman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.