title: Python Pandas: How to merge based on an "OR" condition?
body: <p>Let's say I have two dataframes, and the column names for both are:</p>
  
  <pre><code>table 1 columns:
  [ShipNumber, TrackNumber, ShipDate, Quantity, Weight]
  table 2 columns:
  [ShipNumber, TrackNumber, AmountReceived]
  </code></pre>
  
  <p>I want to merge the two tables based on both ShipNumber and TrackNumber. 
  However, if i simply use merge in the following way (pseudo code, not real code):</p>
  
  <pre><code>tab1.merge(tab2, "left", on=['ShipNumber','TrackNumber'])
  </code></pre>
  
  <p>then, that means the values in both ShipNumber and TrackNumber columns from both tables MUST MATCH. </p>
  
  <p><strong>However</strong>, in my case, sometimes the ShipNumber column values will match, sometimes the TrackNumber column values will match; <strong>as long as one of the two values match for a row</strong>, I want the merge to happen. </p>
  
  <p>In other words, if row 1 ShipNumber in tab 1 matches row 3 ShipNumber in tab 2, but the TrackNumber in two tables for the two records do not match, I still want to match the two rows from the two tables.</p>
  
  <p>So basically this is a either/or match condition (pesudo code):</p>
  
  <pre><code>if tab1.ShipNumber == tab2.ShipNumber OR tab1.TrackNumber == tab2.TrackNumber:
      then merge
  </code></pre>
  
  <p>I hope my question makes sense... 
  Any help is really really appreciated!</p>
  
  <p>As suggested, I looked into this post:
  <a href="https://stackoverflow.com/questions/43925603/python-pandas-merge-with-or-logic?rq=1">Python pandas merge with OR logic</a>
  But it is not completely the same issue I think, as the OP from that post has a mapping file, and so they can simply do 2 merges to solve this. But I dont have a mapping file, rather, I have two df's with same key columns (ShipNumber, TrackNumber)</p>