Situation
There is an df that is holding elements, each element could have different types:
df = pd.DataFrame({
'id':[1,1,2,2,2],
'type':['a','b','a','b','c']
})
This df should be filtert against a list and show only the ids that types contains all the list:
['a','b','c']
Expected id in this case is: 2 cause all of its types a,b,c are in the list.
The approaches that I tried
Grouping by id and get a list of its types, but no idea how to compare against the list or to apply something like set(list).issubset(types):
df = df.groupby('id')['type'].apply(list)
df.reset_index(name = 'types')
Query against list, but with result that are all types in:
df.query('type in ["a","b","c"]')
Would be great to get a hint - Thanks