There can be several ways to find the number of elements greater than a value in a DataFrame. One way is to use the count() function that returns the number of non-NA cells for each column or row.If you do df[df>k], you will get a new dataframe with NaN for cells that are less than 'k'. You can then apply the count() function to the new dataframe.
Here is an example:
>>> import numpy as np>>> import pandas as pd>>> np.random.seed(7)>>> df = pd.DataFrame({'a':np.random.randint(5,50,10), 'b':np.random.randint(5,50,10)})>>> df a b0 9 301 30 472 8 313 24 134 28 445 44 436 33 97 19 128 28 499 13 5>>> df1=df[df>10]>>> df1 a b0 NaN 30.01 30.0 47.02 NaN 31.03 24.0 13.04 28.0 44.05 44.0 43.06 33.0 NaN7 19.0 12.08 28.0 49.09 13.0 NaN>>> df1.count()a 8b 8