Get array with another array indexing with NumPy

Aziiz TEBAA
arr_1 = np.array([5, 1, 6, 3, 3, 10, 3, 6, 12])
arr_2 = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90])
arr_idx_num_3 = np.where(arr_1 == 3)[0]
print(arr_idx_num_3)  ## [3 4 6]

#how to i get this array Numpy with "arr_idx_num_3"

arr_2 = [40 50 70]
eshirvana

Just use it like:

print(arr_2[arr_idx_num_3])

output:

>>> [40 50 70]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related