Finding the duplicate values between all columns and sort in new column with Pandas?
Given your input data is saved in a variable df, I count the values which occur in all 4 unique columns as follows:
import pandas as pd
import numpy as np

output = (
    df
    .melt()
    .drop_duplicates()
    .groupby(&quot;value&quot;)
    .agg(count=(&quot;value&quot;, &quot;count&quot;))
    .reset_index()
)
output[&quot;SIM&quot;] = np.where(output[&quot;count&quot;] == 4, &quot;SIM&quot;, &quot;NON-SIM&quot;)
output = output.pivot(columns=&quot;similarity&quot;, values=&quot;value&quot;)

print(output)

similarity  NON-SIM SIM
0           NaN     a
1           b       NaN
2           c       NaN
3           NaN     d
4           dc      NaN
5           dx      NaN
6           f       NaN
7           g       NaN
8           NaN     s
9           t       NaN
10          w       NaN
11          x       NaN
12          y       NaN