I have 2 columns (input & target) in the pandas which includes the list. The purpose is to find how many common item in these 2 lists and save the result in the new column "common"
For the 1st row, only have 'ELITE' in common. For the 2nd row, both 'ACURAWATCH' & 'PLUS' exist in both list.
Input:
frame = pd.DataFrame({'input' : [['MINIVAN','TOURING','ELITE'], ['4D','SUV','ACURAWATCH','PLUS']], 'target' : [['MINI','TOUR','ELITE'], ['ACURAWATCH','PLUS']]})
Expect Output:
frame = pd.DataFrame({'input' : [['MINIVAN','TOURING','ELITE'], ['4D','SUV','ACURAWATCH','PLUS']], 'target' : [['MINI','TOUR','ELITE'], ['ACURAWATCH','PLUS']], 'common' :[1, 2]})