Can anyone help me understand why list comprehension generates different results when I just changed series to list?
ser1 = pd.Series([1, 2, 3, 4, 5])
ser2 = pd.Series([4, 5, 6, 7, 8])
[i for i in ser1 if i not in ser2]
# the output is [5]
but if I change to loop through list inside list comprehension, I get the result I want:
l1 = [1, 2, 3, 4, 5]
l2 = [4, 5, 6, 7, 8]
[i for i in l1 if i not in l2]
# the output is [1, 2, 3]
Why series generates wrong answer?
Thanks in advance.