title: How to merge two pandas dataframes so that even partial matches are placed side by side in output?
body: <p>I have the following 2 dataframes (simplified version):</p>
  <p><strong>df1:</strong></p>
  <pre><code>ID_A,ID_B,SAMPLE_ID,VARIANT_A
  XXX,YYY,12_23456,GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24]
  XXX,YYY,12_23456,GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.40]
  </code></pre>
  <p><strong>df2:</strong></p>
  <pre><code>ID_A,ID_B,SAMPLE_ID,VARIANT_B
  XXX,YYY,12_23456,GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24]
  XXX,YYY,12_23456,GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.17]
  XXX,YYY,12_23456,GENED NM_999 c.231-?_234+?del [DELDUP] [HET] [0.0.169:z5.02]
  </code></pre>
  <p>There are cases where the entire <code>VARIANT</code> row will match between the dfs (as can be seen for <code>GENEA</code>),
  and there are cases where there's a partial match, where all components of the <code>VARIANT</code> row will match except for the last element (e.g. <code>[0.0.174:z7.17]</code>), as can be seen in <code>GENEB</code>.</p>
  <p><strong>Question:</strong> How can I merge the 2 dfs such that it still keeps the partial matches side by side?</p>
  <p><strong>What I've tried:</strong></p>
  <pre><code>df = pd.merge(df1, df2, left_on=[&quot;ID_A&quot;,&quot;ID_B&quot;,&quot;SAMPLE_ID&quot;,&quot;VARIANT_A&quot;], right_on=[&quot;ID_A&quot;,&quot;ID_B&quot;,&quot;SAMPLE_ID&quot;,&quot;VARIANT_B&quot;], how=&quot;outer&quot;)
  </code></pre>
  <p><strong>Outcome:</strong></p>
  <pre><code>ID_A,ID_B,SAMPLE_ID,VARIANT_A,VARIANT_B
  XXX,YYY,12_23456,GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24],GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24]
  XXX,YYY,12_23456,GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.40],NA
  XXX,YYY,12_23456,NA,GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.17]
  XXX,YYY,12_23456,NA,GENED NM_999 c.231-?_234+?del [DELDUP] [HET] [0.0.169:z5.02]
  </code></pre>
  <p>It puts the exact matching GENEA rows together, but I also want it to put the partially-matching rows together and then have a column indicating whether there was a full match.</p>
  <p><strong>Expected outcome:</strong></p>
  <pre><code>ID_A,ID_B,SAMPLE_ID,VARIANT_A,VARIANT_B,FULL_MATCH
  XXX,YYY,12_23456,GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24],GENEA NM_666 c.5528-?_5769+?dup [DELDUP] [HET] [0.0.263:z5.24],YES
  XXX,YYY,12_23456,GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.40],GENEB NM_777 c.80-?_164+?del [DELDUP] [HET] [0.0.174:z7.17],NO
  XXX,YYY,12_23456,NA,GENED NM_999 c.231-?_234+?del [DELDUP] [HET] [0.0.169:z5.02],NO
  </code></pre>