I have 2 pandas series of dictionaries as follows:
series_1 = [{'id': 'testProd_1', 'q1':'Foo1', 'q2': 'Bar1'},
{'id': 'testProd_2', 'q1':'Foo2', 'q2': 'Bar2'},
{'id': 'testProd_3', 'q1':'Foo3', 'q2': 'Bar3'},
{'id': 'testProd_5', 'q1':'Foo5', 'q2': 'Bar5'}
]
series_2 = [{'q1':'Foo1', 'q2': 'Bar1'},
{'q1':'Foo2', 'q2': 'Bar2'},
{'q1':'Foo3', 'q2': 'Bar3'},
{'q1':'Foo4', 'q2': 'Bar4'},
{'q1':'Foo5', 'q2': 'Bar{5}'}]
I am trying to compare the two pandas series and provide the id from series_1 to all matching series_2 dicts.
expected_result = [{'id': 'testProd_1', 'q1':'Foo1', 'q2': 'Bar1'},
{'id': 'testProd_2', 'q1':'Foo2', 'q2': 'Bar2'},
{'id': 'testProd_3', 'q1':'Foo3', 'q2': 'Bar3'},
{'id': 'testProd_5', 'q1':'Foo5', 'q2': 'Bar{5}'}]
Series equal doesn't work since one series has an additional key value pair ('id') for each dict. Do I have to loop through each individual entry? What is the most efficient approach to get the expected_result?
I am working with 2 large datasets where I am trying to link the id from one series to another. The data is basically the same but sometimes the values in some of the key value pairs have some erroneous characters (ex: {5}, (5), {ex.5}).
Any suggestions?
Thanks