I want to check if elements of list1 are in list2. if so, I want to add up the elements.
It works without an extern .csv file:
list1 = [1,2,3,4,5]
list2 = [1,2,3]
c = sum(el in list1 for el in list2)
print(c)
But when I import a .csv file, the expected answer is incorrect.
Expected answer: 6
import pandas as pd
list1 = pd.read_csv(r"list1.csv")
list2 = pd.read_csv(r"list2.csv")
cs = sum(el in list1 for el in list2)
print(cs)
I think it has something to do with the way I import the files? Or do I need to convert the objects? Your help is welcome :)