0

I have a data frame df as below and I want to count how many scores are greater than 10 in df score column.

data in dataframe df is like :

code score   
A    11      
B    9     
c    14    
D    11   

and as output I want 3.

Michele Tonutti
  • 4,298
  • 1
  • 21
  • 22
priya
  • 67
  • 8

1 Answers1

2

Use sum of boolean mask - count Trues values like 1s:

out = df['score'].gt(10).sum()
#or
#out = (df['score'] > 10).sum()
print (out)
3
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252