I have the following DF1 with 100 columns (col_1
to col_100
), and I want to put a condition to count only the columns (col_1
to col_100
) with value > 50 against every item in column Item
. In Excel, it's fairly easy - use the function COUNTIF()
. How can we achieve the same in Python?
Item col_1 col_2 col_3 col_4 col_5 col_6 col_7 …
item_1 10 5 6 9 4 6 77 …
item_2 3 5 66 76 7 89 33 …
In above table, outcome should be:
Item Result
item_1 1
item_2 3