2
I’m starting in python and have trouble automating some calculations. I have a Dataframe with 8 columns [A, B, C, D, E, F, G, H] and 150 rows.
I need to count how many times 2 columns are equal to each other, for example: A==B, A==C, A==D... B==C, B==D... Then I need to divide the amount of equalities by the total number of rows (150) and store this result in another table. So far I’ve achieved this:
condicao = (df['A']==df['B'])
sum(condicao)
x = sum(condicao)/150
print(x)
With this code I already get the result I need, however, it would be necessary to create 28 conditions. Any idea how to summarize this?
Hugs.
Columns need to be equal in all entries or you want to count the number of entries in common between two columns?
– Leonardo Bohac