I wonder if there is a way to merge two list of dictionary base on a single key:value in each dictionary. As I tried to search and some cases, they seem did not match what I needed.
Suppose that I have two lists of dictionary as below:
[{'standoff_id': 1, 'entity_type': 'Concept', 'offset_start': 13, 'offset_end': 18, 'word': 'wheat'}, {'standoff_id': 2, 'entity_type': 'Concept', 'offset_start': 26, 'offset_end': 30, 'word': 'corn'}, {'standoff_id': 3, 'entity_type': 'Concept', 'offset_start': 61, 'offset_end': 67, 'word': 'barley'}]
[{'standoff_id': 1, 'concept_id': '8373'}, {'standoff_id': 2, 'concept_id': '12332'}, {'standoff_id': 3, 'concept_id': '823'}]
Those two lists always have the same length and I want to merge these two lists i.e each dictionary in parallel based on the 'standoff_id': id.
My desired output is:
[{'standoff_id': 1, 'entity_type': 'Concept', 'offset_start': 13, 'offset_end': 18, 'word': 'wheat', 'concept_id': '8373'}, {'standoff_id': 2, 'entity_type': 'Concept', 'offset_start': 26, 'offset_end': 30, 'word': 'corn', 'concept_id': '12332'}, {'standoff_id': 3, 'entity_type': 'Concept', 'offset_start': 61, 'offset_end': 67, 'word': 'barley', 'concept_id': '823'}]
Any help would be much appreciated! Thank you!