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
import pandas as pd
import numpy as np
data = {'Col1' : [4,5,6,7], 'Col2' : [10,20,30,40], 'Col3' : [100,50,-30,-50], 'Col4' : ['AAA', 'BBB', 'AAA', 'CCC']}
target_array = np.array(['AAA', 'CCC', 'EEE'])
df = pd.DataFrame(data=data, index = ['R1','R2','R3','R4'])
df['in_col'] = df['Col4'].apply(lambda x: x in target_array)
Is this what you were looking for? Then you can groupby the new column and query the True elements.