I'm trying to solve a really simple code. I have a dataframe where I want to use a Count If per row. The problem is that the result is that it counts all symbols per row, even if the condition is not met.
I'm probably missing someting.
This is the code I'm trying where I want to count how many number of 2 there are per row.
Twos = (df[cols] == 2).count(axis=1)
print(Twos)
I have 10 columns and it return 10 for all 1 million rows and this is not the correct outcome.