[Solved] Subsetting the data frame and applying cumulative operation on multiple columns


Hopefully I got it this time:

subdf = df.iloc[3:, 1:4]
df['flag'] = 1 if subdf.values.sum()/subdf.size >= 0.1 else 0

output:

  unit  A  B  C  row_num  flag
0  ABC  1  1  1        7     1
1  DEF  1  1  1        6     1
2  GEH  1  1  1        5     1
3  IJK  0  1  0        4     1
4  DEF  0  1  0        3     1
5  XRF  0  1  0        2     1
6  BRQ  1  0  1        1     1

8

solved Subsetting the data frame and applying cumulative operation on multiple columns