I'm trying to make a third list which is a intersection of 2 list(This lists I got from pandas dataframe). Now for list2 it is of float and first one is integer and now if I try to compare them third one will be empty one. I tried to convert list2 into integer but that's throwing an error for NaN ("cannot convert float NaN to integer"). Now how to convert that list2 into a list of integers?
Here's the snapshot of second list.List2
And Here's my code:
def intersection(lst1, lst2):
lst3 = [value for value in lst1 if value in lst2]
return lst3
list1_NY = df.New_york.values.tolist()
list2_NY = df.NY_11220.values.tolist()
list2_NY = [int(x) for x in list2_NY]
com_list_NY = intersection(list1_NY, list2_NY)