I have a reference dataframe that contains a column of ID's and two columns with ID attributes (function and chapter). I want to cross reference two other data frames to see if: 1) the IDs from each of the two dataframes match the reference dataframe. 2) Of those matching IDs from the reference dataframe and the other two dataframes Im comparing, pull the corresponding data from the reference dataframe (i.e., function/chapter) and align to matched ID's.
I have tried writing a function a long with sorting the values into a list or dictionary and pull all those that align and those that don't align.
to match ID's
Updated_list = []
Mismatch_list = []
for key in res.keys():
if key in Expanded_dic.keys():
Updated_list.append(key)
elif key not in Expanded_dic.keys():
Mismatch_list.append(key)
print(Updated_list)
Reference DF: ID | Chapter | Function
Of the two dataframes with their own ID column, I want to output a new dataframe that shows matching ID's as well as it's corresponding Chapter and Function value (if matched).
Expected output: enter image description here