Is there an efficient way to reverse a DF column that contains boolean values? i.e. swapping between the True and False values. For example:
df = pd.DataFrame({'col1':[True, True, True, False],
'col2':[False, True, True, False]})
I want to select the dataframe based on the opposite of col1 & col2. Basically I have tried:
not( df['col1'] & df['col2'])
I'm hoping to get a Series with the following values:
True
False
False
True
but got the following error message:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().