suppose I have a dataframe in the form of:
a b c
89 9 2
90 5 5
10 70 20
25 50 25
my goal is to remove the rows where 100 minus the sum of these three columns is greater than 0.5.
how can I do that?
suppose I have a dataframe in the form of:
a b c
89 9 2
90 5 5
10 70 20
25 50 25
my goal is to remove the rows where 100 minus the sum of these three columns is greater than 0.5.
how can I do that?
One solution:
(100 - df.sum(1)).le(0.5)
This is a boolean mask that you can give it to a dataframe:
df[(100 - df.sum(1)).le(0.5)]
Well here is what I came up with and it works just fine:
indexNames = df[((100 - df1['a'] - df['b'] - df['c']).abs() > 0.5)].index
df.drop(indexNames , inplace=True)