For a data frame df, it has a column col contains list value:
df
col
list
id col 1 [1, 10, 23] 2 [2, 11, 19, 29] ..
option using apply df.col.apply(lambda x: 1 in x)
apply
df.col.apply(lambda x: 1 in x)
demo df[df.col.apply(lambda x: 1 in x)]
df[df.col.apply(lambda x: 1 in x)]
try read the "apply" function in pandas document.
df['has_element'] = df['col'].apply(lambda x: element in x)