Python Forum
Comparing items from 2 lists of dictionaries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparing items from 2 lists of dictionaries
#2
The dictionaries can have different keys, and if they have the same key they can have different values stored. It's not clear to me which sort of difference you are looking for. What do you want to do if the key doesn't exist? What do you want to do if the key exists but has a different value? What do you want to do if the same key in each has the same value?

For all these cases, you'll probably want to loop over the keys in dictA and examine dictB on each of them to see if it matches. Then store or mark the case that you need.
Reply


Messages In This Thread
RE: Comparing items from 2 lists of dictionaries - by bowlofred - Sep-14-2020, 09:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  comparing 2 lists rwahdan 2 1,657 Jul-18-2021, 06:30 PM
Last Post: DeaD_EyE
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,433 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Comparing Items Different Data Frames With a WHILE Loop JoeDainton123 1 1,978 Jul-30-2020, 04:11 AM
Last Post: scidam
  Searching through Nested Dictionaries and Lists Dave_London 1 8,265 Jul-09-2020, 03:36 PM
Last Post: mrdominikku
  How to put the items of one list in new generated lists Bobbear 1 1,678 Jun-12-2020, 06:08 AM
Last Post: buran
  Compare Two Lists and Replace Items In a List by Index nagymusic 2 2,920 May-10-2020, 05:28 AM
Last Post: deanhystad
  Add items from one list to list of lists PUP280 5 3,015 May-05-2020, 03:47 PM
Last Post: PUP280
  putting 2 lists items side by side Jiwan 1 2,278 Apr-30-2020, 01:04 AM
Last Post: Larz60+
  Finding value in nested dictionaries with lists mart79 16 8,251 Mar-08-2020, 08:16 PM
Last Post: ndc85430
  Can't seem to figure out how to put all of the lists items from a loop into 1 list Cosmosso 4 2,834 Feb-21-2020, 02:40 PM
Last Post: Cosmosso

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020