title: Compare dataframe columns by row value & select the one with matched-pattern
body: <p>I have a df as shown below:</p>
  
  <pre><code>id1     id2     id3    id4    id5
  
  9890    abc123  CI652  125    nan
  
  156     CI951   9895   nan    nan
  
  CI632   198     nan    nan    nan
  
  nan     nan     145    nan    CI258
  
  9892    9893    nan    nan    nan
  
  abc556  nan     abc887 nan    CI642
  </code></pre>
  
  <p>I want to look through all the columns and select a value based on priority:</p>
  
  <p><strong>abc* > 98* > anything except "nan" > nan</strong></p>
  
  <p>Based on the value selected, I want to create &amp; populate a new df / column. Expected output is as below:</p>
  
  <pre><code>id1     id2     id3    id4    id5    output
  
  9890    abc123  CI652  125    nan    abc123
  
  156     CI951   9895   nan    nan    9895
  
  CI632   198     nan    nan    nan    CI632
  
  nan     nan     145    nan    CI258  145
  
  9892    9893    nan    nan    nan    9892
  
  abc556  nan     abc887 nan    CI642  abc556
  </code></pre>
  
  <p>My logic is to iterate over each row in the df using a for-loop &amp; then compare values by priority using some if-else logic</p>
  
  <p>Is there a better way to achieve this? Any insights are appreciated. TIA!</p>