When I select by chaining different conditions with "AND" the selection works fine. When I select by chaining conditions with "OR" the selection throws an error.
>>> import pandas as pd
>>> import numpy as np
>>> df = pd.DataFrame([[1,4,3],[2,3,5],[4,5,6],[3,2,5]],
... columns=['a', 'b', 'c'])
>>> df
a b c
0 1 4 3
1 2 3 5
2 4 5 6
3 3 2 5
>>> df.loc[(df.a != 1) & (df.b < 5)]
a b c
1 2 3 5
3 3 2 5
>>> df.loc[(df.a != 1) or (df.b < 5)]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pandas/core/generic.py", line 731, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I would expect it to return the whole dataframe as all rows meet this condition.