title: Identifying the columns having duplicate column value with Different column name in python
body: <p>How to identify the columns in a data frame with same column_value But with different column name , we need to list both the column , here i am able to list only one of them.  </p>
  
  <pre><code>    from pandas import DataFrame
      import numpy as np
      import pandas as pd
  
  raw_data = {
          'id': ['1', '2', '2', '3', '3'],
          'name': ['A', 'B', 'B', 'C', 'D'],
          'age' : [1, 2, 2, 3, 3],
  'name_dup': ['A', 'B', 'B', 'C', 'D'],
  'age_dup': [1, 2, 2, 3, 3]}
  df = pd.DataFrame(raw_data, columns = ['id', 'name','age','name_dup','age_dup'])
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wCBsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wCBsB.png" alt="Data View"></a> </p>
  
  <p>Like in the image ,one can observe that <code>name</code> and <code>name_dup</code> have same column values but column names are different With the below Function i am able to get only <code>name</code> as an output as shown below where expected is <code>name_dup</code>.    </p>
  
  <pre><code>    def duplicate_columns(frame):
      groups = frame.columns.to_series().groupby(frame.dtypes).groups
      dups = []
  
      for t, v in groups.items():
  
          cs = frame[v].columns
          vs = frame[v]
          lcs = len(cs)
  
          for i in range(lcs):
              iv = vs.iloc[:,i].tolist()
              for j in range(i+1, lcs):
                  jv = vs.iloc[:,j].tolist()
                  if iv == jv:
                      dups.append(cs[i])
                      break
  
      return dups 
  
   duplicate_columns(df)
  </code></pre>
  
  <p>Output of Above Code is Shown Below :  </p>
  
  <p><a href="https://i.stack.imgur.com/SjQvj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SjQvj.png" alt="Actual Output"></a> </p>
  
  <p><strong>Expected List Duplicate columns Output</strong>  </p>
  
  <p><code>name</code> and <code>name_dup</code> <code>age</code> and <code>age_dup</code>.  </p>
  
  <p>Here further to This keep drop any one of the column and rename the new column from <code>list_check</code> if we have a list of column name :  </p>
  
  <pre><code>list_check  =  ['name','age']  
  </code></pre>
  
  <p><strong>Expected DataFrame</strong>  </p>
  
  <p><a href="https://i.stack.imgur.com/khYfo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/khYfo.png" alt="Expected Output"></a></p>
  
  <p><strong>Note</strong> : It is not compulsory that it will always be <code>colname</code> will be <code>colname_dup</code> it can also be <code>lname</code>. </p>