I am trying to get see if the pandas dataframe columns as values from a list.
df = pd.DataFrame({'id':[np.nan,2,3,4,5,6],
'column1':[np.nan,10,15,20,25,25],
'column2':[np.nan,4,6,8,10,np.nan],
'column3':[np.nan,6,9,12,np.nan,15],
'column4':[np.nan,np.nan,np.nan,np.nan,np.nan,np.nan]})
lst = ['4','6','10','25']
cols = ['column1','column2','column3','column4']
I am trying to check the value of lst in the multiple columns in df and get the column names of the df if value exist in the df.
The result I am looking for is:

The result I am getting is in True and False.
I was able to get result but not result1:
I got result by
m1 = df[cols].isin(lst)
m2 = pd.DataFrame((~m1.any(1)).to_numpy()[:, None] & df[cols].eq(2).to_numpy(),
index=m1.index, columns=m1.columns)
m = (m1 | m2)
df['result'] = m.where(m).stack().reset_index().groupby('level_0')['level_1'].agg(list)