Q:

Return columns with a row containing substring in an array

I have df with n columns (named as col'n') and 'name' column, I want to loc any row with col'n' have any keywords in 'searchkey' array.
It seems the list comprehension cannot apply in df column names list.
df[[c for c in df.columns if c[3:] = 'Col'].str.isin(searchkey))

Also, I tried to use apply function, but still face the problem.
df = pd.DataFrame({'name':['AA','BB','CC','DD','EE','FF'],
                   'col1':['mn','mxn','ca','sd','xa','ac'], 
                   'col2':['m','naa','x','ddn','q','y'],
                   'col3':['mn','mddn','csfd','sad','xxa','aad'], 
                   ... ... 
                   'coln':['sfn','mxc','cxa','sxxd','xada','axxc'],                    
})

searchkey = ['xx', 'aa', 'dd']

def func(x):
    return [x.columns] in searchkey  ## Error

df.apply(func, axis=1)

Any help is greatly appreciated!

A:

Try this
df = df[df.isin(search_key).any(1)]

