'Python - How to merge 2 dataframes together, but 2 columns either 1 will match and the other might not

So I have a 2 dataframe

As you can see the REF_NUM in the other table has match REF_NUM, but sometimes it doesn't, however APPLID matches so I want to see between two column in those two tables what matches and if so how can I get the count of it

enter image description here

The way I want it to show up:

Trying to do this in python

I tried doing a merge, but thinking through that concept I don't think it works in this situation.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source