pandas: multiple conditions while indexing data frame – unexpected behavior

I am filtering rows in a dataframe by values in two columns. For some reason the OR operator behaves like I would expect AND operator to behave and vice versa. My test code: import pandas as pd df = pd.DataFrame({‘a’: range(5), ‘b’: range(5) }) # let’s insert some -1 values df[‘a’][1] = -1 df[‘b’][1] = … Read more

How can I obtain the element-wise logical NOT of a pandas Series?

I have a pandas Series object containing boolean values. How can I get a series containing the logical NOT of each value? For example, consider a series containing: True True True False The series I’d like to get would contain: False False False True This seems like it should be reasonably simple, but apparently I’ve … Read more