Below is my DF
df= pd.DataFrame({'col1': ['[7]', '[30]', '[0]', '[7]'], 'col2': ['[0%, 7%]', '[30%]', '[30%, 7%]', '[7%]']})
col1 col2
[7] [0%, 7%]
[30] [30%]
[0] [30%, 7%]
[7] [7%]
The aim is to check if col1 value is contained in col2 below is what I've tried
df['test'] = df.apply(lambda x: str(x.col1) in str(x.col2), axis=1)
Below is the expected output
col1 col2 col3
[7] [0%, 7%] True
[30] [30%] True
[0] [30%, 7%] False
[7] [7%] True