This should be much faster:
df = pd.DataFrame({'list1': [["a","b"],
["a","c"],
["a","d"],
["b","c"],
["b","d"],
["c","d"]]*100})
df2 = pd.DataFrame({'list2': [["a","b","c","d"],
["a","b"],
["b","c"],
["c","d"],
["b","c"]]*100})
list2 = df2['list2'].map(set).tolist()
df['occurance'] = df['list1'].apply(set).apply(lambda x: len([i for i in list2 if x.issubset(i)]))
Using your approach:
%timeit for index, row in df.iterrows(): df.at[index, "occurrence"] = df2["list2"].apply(lambda x: all(i in x for i in row['list1'])).sum()
1 loop, best of 3: 3.98 s per loop
Using mine:
%timeit list2 = df2['list2'].map(set).tolist();df['occurance'] = df['list1'].apply(set).apply(lambda x: len([i for i in list2 if x.issubset(i)]))
10 loops, best of 3: 29.7 ms per loop
Notice that I've increased the size of list by a factor of 100.
EDIT
This one seems even faster:
list2 = df2['list2'].sort_values().tolist()
df['occurance'] = df['list1'].apply(lambda x: len(list(next(iter(())) if not all(i in list2 for i in x) else i for i in x)))
And timing:
%timeit list2 = df2['list2'].sort_values().tolist();df['occurance'] = df['list1'].apply(lambda x: len(list(next(iter(())) if not all(i in list2 for i in x) else i for i in x)))
100 loops, best of 3: 14.8 ms per loop