Home > Enterprise >  Sum of range of values in DataFrame column
Sum of range of values in DataFrame column

Time:07-28

How would I figure out how many prediction values are greater than 77.36?

    formula prediction  density score   index
0   CaSe2O7 138.789612  9.307914    25.664856   100354
1   YCu8    138.487381  3.889000    25.366763   643729
2   YCd8    136.493805  16.628878   24.559599   642274
3   Ba(ClO4)2   124.093674  1.649017    23.623096   28827
4   BaCa2Cu3O5  120.059601  9.005068    21.755612   40058
... ... ... ... ... ...
694393  Ba2Y(CuO2)4 80.074173   2792.744442 -185.443640 32520
694394  Ba(CoAs)2   1.535048    3439.187195 -199.425291 28829
694395  Ba2YMn3O7   78.063133   3709.714216 -203.883311 32592
694396  Ba2Pr(CuO2)4    26.273754   3266.852940 -209.020531 31612
694397  LiLa14(Cu3O14)2 24.059904   10000.958722    -630.506687 350264
694398 rows × 5 columns

I know you would want the sum where df['prediction'] > 77.36

CodePudding user response:

Sum the boolean mask:

(df['prediction'] > 77.36).sum()

CodePudding user response:

If You want to get all the value greater than 77.36 (Filtering DataFrame)

df[df['prediction'] > 77.36]

If you want to find total number of value greater than 77.36 the you can use

(df['prediction'] > 77.36]).sum()
  • Related