KGBeans KGBeans - 2 months ago 18
Python Question

Matching columns from multiple dataframes in pandas

I have 2 dataframes with a column of ['Names'] and ['Addresses']. I would like to get pandas to print the row in the second dataframe if it matches the name and address from the first.


consider d1 and d2

d1 = pd.DataFrame(dict(Names=list('ABCDEFG'),
                       Addressess=[1, 2, 3, 4, 5, 6, 7]))

enter image description here

d2 = pd.DataFrame(dict(Names=list('FGHIJ'),
                       Addressess=[6, 7, 8, 9, 10]))

enter image description here

then use merge


enter image description here