Reputation: 9363
I have two lists, let's call them list1
and list2
.
list1
is the main list which contains all the values of my data.
list2
contains certain values that have to be removed from list1
. (You can say it is sort of like a sublist of list1
)
len(list1) = 13357
len(list2) = 1751
So to remove values of list2
from list1
I do:
new_list = [x for x in list1 if x not in list2]
So what you would expect is for new_list
to have a length:
len(new_list) = len(list1) - len(list2) = 13357 - 1751 = 11606
However my new_list
has a length = 11584 !!!
How is this possible????!!!!!
EDIT:
I obtained my list2
from list1
using a calculation. I also checked for similar values using set(list1) & set(list2)
list2
is actually a quadrant of list1
, it is a follow up of THIS QUESTION I had asked previously.
So from the above link you can see that I have RA and DEC co-ordinates of my data. In the example, assume list1
is my RA.
So once I have my quandrants, I apply:
for a,b in zip(sliceno,list1):
if a == 0:
list2.append(a)
I know this is a follow-up of my previous question, so please bare with the complications!!
Upvotes: 2
Views: 164
Reputation: 1163
This is almost for sure that list2 has 11606 - 11584 = 22 repeated elements. (And because of list2 is a subset of list1 then they exist also in list1)
Upvotes: 2