Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy find index of matching values

import numpy as np
# init arrays
a = np.array([1,2,3,2,3,4,3,4,5,6])
b = np.array([7,2,10,2,7,4,9,4,9,8])

#using enumerate, list comprehension and set
print([key for key, val in enumerate(a) if val in set(b)])
# output
# [1, 3, 5, 7]
Comment

PREVIOUS NEXT
Code Example
Python :: Generation of Random Numbers in python 
Python :: python sort case insensitive 
Python :: fastest sorting algorithm java 
Python :: string without space pythonm 
Python :: print function python 
Python :: python port forwarding 
Python :: python encoding declaration 
Python :: 2)Write a function that checks whether a number is in a given range (inclusive of high and low) python 
Python :: selenium check if driver is open python 
Python :: pytorch get tensor dimension 
Python :: first non repeating charcter in string ython 
Python :: how to access dictionary inside an array python 
Python :: number data type in python 
Python :: skeppy python 
Python :: Math Module radians() Function in python 
Python :: printing in python 
Python :: how to add all values in a list python without using sum function 
Python :: reciprocal python 
Python :: mayeutica 
Python :: eror api/kernelsUntitled.ipynb?kernel_name=python3 
Python :: change group box title font size 
Python :: Installez django-cruds-adminlte 
Python :: bolumden kalan python 
Shell :: Could not find the implementation for builder @angular-devkit/build-angular:dev-server 
Shell :: uninstall node js and npm ubuntu 
Shell :: sudo: unzip: command not found 
Shell :: ps not found 
Shell :: install ext-intl php7.4 ubuntu 
Shell :: list used ports on mac 
Shell :: kill the port in mac 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =