title: Loop over columns to compare two columns at a time in a dataframe and add one summary column based on each comparison result
body: <p><a href="https://i.stack.imgur.com/JM32n.png" rel="nofollow noreferrer">df1.csv</a></p>
  
  <p><a href="https://i.stack.imgur.com/AYehv.png" rel="nofollow noreferrer">df2.csv</a></p>
  
  <p>After executing the code below,</p>
  
  <blockquote>
    <p>df1.merge(df2, on=['Customer_id'], indicator='Status', how='outer')</p>
  </blockquote>
  
  <p>I get,</p>
  
  <p><a href="https://i.stack.imgur.com/T4W4p.png" rel="nofollow noreferrer">df3.csv</a></p>
  
  <p>Now I want to compare whether all elements in Name_x is equal to Name_y or not, similarly for other columns as well. What i am doing is comparing it individually. Here is my code:</p>
  
  <blockquote>
    <p>df3.assign(Status1=df3.Name_x == df3.Name_y)</p>
    
    <p>df3.assign(Status2=df3.Age_x == df3.Age_y)</p>
  </blockquote>
  
  <p>and so on</p>
  
  <p>After doing above i get,</p>
  
  <p><a href="https://i.stack.imgur.com/0PlEj.png" rel="nofollow noreferrer">df4.csv</a></p>
  
  <p>Can i write <strong>for loop</strong> so that i do not have to write the code </p>
  
  <blockquote>
    <p>df3.assign()</p>
  </blockquote>
  
  <p>individually for comparing every two columns?</p>
  
  <p>and most importantly my <strong>final status</strong> column should look like this,</p>
  
  <p><a href="https://i.stack.imgur.com/emJZF.png" rel="nofollow noreferrer">output</a></p>
  
  <p>what i am doing is thinking to write <strong>if elif</strong> like this:</p>
  
  <blockquote>
    <p>def f(row):</p>
  
  <pre><code>if row['Status1'] == 'True' and row['Status2'] == 'False':
      val = 'Matching for column {Name}'
  elif row['Status1'] == 'False' and row['Status1'] == 'True':
      val = 'Matching for column {Age}
  elif row['Status1'] == 'False' and row['Status1'] == 'False':
      val = 'Not Matching at all' #and so on...
  return val
  </code></pre>
  </blockquote>
  
  <p>This is okay if one want to write <strong>if elif</strong>  only on two columns <strong>Status1 and Status2</strong> and becomes lengthy if one want to write <strong>if elif</strong> on more than 2 columns. Can i get the desired output in few lines of code if i have column <strong>Status3</strong> also?</p>