I need to effectively do an inner join implemented in Python.
I have 2 data sets which come from separate sources but share a common key.
Lets say (for the sake of argument) that they look like this:
person_likes = [{'person_id': '1', 'food': 'ice_cream', 'pastimes': 'swimming'},
{'person_id': '2', 'food': 'paella', 'pastimes': 'banjo'}]
person_accounts = [{'person_id': '1', 'blogs': ['swimming digest', 'cooking puddings']},
{'person_id': '2', 'blogs': ['learn flamenca']}]
How best can I join these two sets of data. I have something like this:
joins = []
for like in person_likes:
for acc in person_accounts:
if like['person_id'] == acc['person_id']:
join = {}
join.update(like)
join.update(acc)
joins.append(join)
print(joins)
This appears to work fine (I haven't tested it extensively), and at first glance looks like the best we can do - but I wonder if there is a know algorithm which is more performant and also if there is a more idiomatic or Pythonic way of doing this?