Not the most efficient one, but by far the most obvious way to do it is:
>>> a = [1, 2, 3, 4, 5]
>>> b = [9, 8, 7, 6, 5]
>>> set(a) & set(b)
{5}
if order is significant you can do it with list comprehensions like this:
>>> [i for i, j in zip(a, b) if i == j]
[5]
(only works for equal-sized lists, which order-significance implies).
Answer from SilentGhost on Stack OverflowHow can I compare two lists in python and return matches - Stack Overflow
How to compare two lists
How do I compare 2 sets of data and separate out only what does now appear in both lists
Heres a website that actually lets you compare playlists. Finds similarities such as shared songs, artists, and albums all in a nice interface side by side
Videos
Not the most efficient one, but by far the most obvious way to do it is:
>>> a = [1, 2, 3, 4, 5]
>>> b = [9, 8, 7, 6, 5]
>>> set(a) & set(b)
{5}
if order is significant you can do it with list comprehensions like this:
>>> [i for i, j in zip(a, b) if i == j]
[5]
(only works for equal-sized lists, which order-significance implies).
Use set.intersection(), it's fast and readable.
>>> set(a).intersection(b)
set([5])
Iโm trying to compare two lists and highlight the names missing from the second list.
Essentially I have a list of 2000 names and a list of 700 names. I want to know/highlight the 1300 names that are not on the second list. New to excel and very confused! Iโm assuming match or vlookup?
TIA for any solutions or formulas.
Hi Rental,
Thanks for contacting us,
Yes, you can use Excel to compare two lists and identify what is unique in each list. Here are the steps:
Method 1: Using Formulas
- **Combine the Lists:**
- Suppose your old inventory is in column A (A2:A100) and the current inventory is in column B (B2:B100).
- In column C, combine both lists using the following formula in cell C2 and drag it down:
=IFERROR(IF(MATCH(B2, $A$2:$A$100, 0), ""), B2)
```
This formula checks if the item in the current inventory list (column B) is found in the old inventory list (column A). If not, it returns the item; otherwise, it returns an empty string.
2. \*\*Filter the Unique Entries:\*\*
- Filter column C to show only the non-empty cells. These are the items that are unique to the current inventory list.
3. \*\*Repeat the Process:\*\*
- Repeat the process in column D but comparing the old inventory list to the current inventory list. Use a similar formula:
```excel
=IFERROR(IF(MATCH(A2, $B$2:$B$100, 0), ""), A2)
```
Filter column D to show only the non-empty cells. These are the items that were present in the old inventory list but are not in the current one.
Method 2: Using Conditional Formatting
1. \*\*Highlight Differences:\*\*
- Select the old inventory list (column A) and then the current inventory list (column B).
- Go to the "Home" tab, click on "Conditional Formatting," and choose "Highlight Cells Rules" -> "Duplicate Values."
- This will highlight the items that appear in both lists.
2. \*\*Filter Unique Entries:\*\*
- Use the "Filter" option to filter out the highlighted cells in both columns. The remaining items in column A are those unique to the old inventory list, and the remaining items in column B are those unique to the current inventory list.
Choose the method that suits you best based on your preferences and requirements.
I hope this helps!
Regards,
Sola
=FILTER(new_list, ISERROR(MATCH(new_serial_column, old_serial_column, 0)))
and
=FILTER(old_list, ISERROR(MATCH(old_serial_column, new_serial_column, 0)))