How can I quickly drop rows where A, B and C are all false? I tried:
df3 = df[~(~(df['A'])& ~(df['B']) & ~(df['C']) )]
df3
com A B C
0 as TRUE FALSE FALSE
1 da TRUE FALSE FALSE
How can I quickly drop rows where A, B and C are all false? I tried:
df3 = df[~(~(df['A'])& ~(df['B']) & ~(df['C']) )]
df3
com A B C
0 as TRUE FALSE FALSE
1 da TRUE FALSE FALSE
drop rows where A, B and C are are all false
With df.sum across axis=1 along with comparison if sum in the row for these coumns is not equal to 0 , using df.ne
out = df[df[['A','B','C']].sum(1).ne(0)].copy()
An alternative using all along axis 1. The 2nd ~ operator directly - directly before df, reversed all False to True. all returns True if all column values are True, then using ~ again to reverse this to index rows that are actually all False:
df3 = df[~(~df[['A', 'B', 'C']]).all(1)]