I am currently using Python 2.7. I currently have three columns in an Excel document all with different integer values in. The amount of values can vary ranging from 10 through to thousands. Basically, what I am looking to do is scan through the column one and compare each value to see if any appear in column two and three. Similarly, I will then do the same with column 2 to see if any appear in column one and three etc….
My thinking on this is to populate the content of each column into a respective list and then iterate over list 1 (column 1) and then run an if statement to compare each iteration value and see if it exists in list 2 (column 2).
My question is, is this the most efficient means of running this comparison? As said, within the three columns, the same number should appear in each of the three columns (it may appear on a number of occasions) and so I’m looking to identify those numbers which appear in each of the three columns.
Thanks
What about using set intersection?
That will give you those values which appear in all three columns.