I have 2 dataframes df1
----------------
Column_df1
------------------
abc
pqr
xyz
and another dataframe is df2
-----------------------------------
Column_df2_value Column_df2
------------------------------------
aaa abc;mkp;txy
jjj tkp;xyz;lmn
ppp vnm;pqr;tmc
dbm krt;qwe;cfe
wer weq;trt;cfd
my resultant dataframe will be following
-------------------------------------
column_df1 column_df2_value
-------------------------------------
abc aaa
pqr ppp
xyz jjj
I am trying to do this
mask=np.where(df1['Column_df1'].tolist().isin(df2['column_df2_value'].str.split(';',expand=True)).any(1))
df["value_exists"]=df1[mask]
but it's not working. What do I need to do to get the following dataframe?
-------------------------------------
column_df1 column_df2_value
-------------------------------------
abc aaa
pqr ppp
xyz jjj