I have a Pandas dataframe where the values are lists:
import pandas as pd DF = pd.DataFrame({\'X\':[[1, 5], [1, 2]], \'Y\':[[1, 2, 5], [1, 3, 5]]}) DF
Use set and issubset:
set
issubset
DF.assign(x_sub_y = DF.apply(lambda x: set(x.X).issubset(set(x.Y)), axis=1))
Output:
X Y x_sub_y 0 [1, 5] [1, 2, 5] True 1 [1, 2] [1, 3, 5] False