I have a dataframe with 0s and 1s
a 1 1 1 1 0 0 0 1 0 0 0 0 0
b 1 1 1 1 0 0 0 1 1 0 0 0 0
c 1 1 1 1 0 0 0 1 1 1 1 0 0
d 1 1 1 1 0 0 0 1 1 1 1 0 0
e 1 1 1 1 0 0 0 0 0 0 0 1 1
f 1 1 1 1 1 1 1 0 0 0 0 0 0
(No header)
I want to make a function that if a certain list with strings given (row name),
the output will be the number of columns exactly matched with strings
For example,
def exact_match(ls1):
~~~~~
return col_num
print(exact_match(['c', 'd']))
>>> 2
The output is 2 because
The exact matching columns are only two.
