I want to compare two list of lists with a dataframe column.
list1=[[r2,r4,r6],[r6,r7]]
list2=[[p4,p5,p8],[p86,p21,p0,p94]]
Dataset:
rid | pid | value |
---|---|---|
r2 | p0 | banana |
r2 | p4 | chocolate |
r4 | p89 | apple |
r6 | p5 | milk |
r7 | p0 | bread |
Output:
[[chocolate,milk],[bread]]
As r2
and p4
occur in the list1[0]
, list2[0]
and in the same row in dataset, so chocolate
must be stored. Similarly r6
and p5
occur in both lists at same position and in the same row in dataset,milk
must be stored.