I have a pandas frame similar to this one:
import pandas as pd
import numpy as np
data = {\'Col1\' : [4,5,6,7], \'Col2\' : [10,20,30,40], \'Col3\' : [100,5
You can use NumPy's in1d -
df.index[np.in1d(df['Col4'],target_array)]
Explanation
1) Create a 1D
mask corresponding to each row telling us whether there is a match between col4's
element and any element in target_array
:
mask = np.in1d(df['Col4'],target_array)
2) Use the mask to select valid indices from the dataframe as final output :
out = df.index[np.in1d(df['Col4'],target_array)]