1
$\begingroup$

I want to compare two records and get the number of columns that have the same value , for example I have two rows, the first row is :

rank rank1 rank2
1 1 3

and the second row is

rank rank1 rank2
1 1 2

the result should be 2 columns have the same value. is there a function in python that is capable of performing something like this?

$\endgroup$
0
$\begingroup$

If your records are in form of a pandas dataframe, then you can use df.columns.duplicated() to know the columns which are duplicated.

$\endgroup$
1
  • $\begingroup$ this is if they are in the same data frame but if it is separated as shown in the example above can we still use it $\endgroup$ – lena Mar 31 at 8:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.