Pandas: Index rows by an OR condition
<p>I'm trying to filter out certain rows in my dataframe that is allowing two combinations of values for two columns. For example columns 'A' and 'B' can just be either 'A' > 0 and 'B' > 0 OR 'A' &lt; 0 and 'B' &lt; 0. Any other combination I want to filter.</p>

<p>I tried the following </p>

<pre><code>df = df.loc[(df['A'] &gt; 0 &amp; df['B'] &gt; 0) or (df['A'] &lt; 0 &amp; df['B'] &lt; 0)]
</code></pre>

<p>which gives me an error: <code>The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</code></p>

<p>I know this is probably a very trivial questions but I couldn't find any  solution to be honest and I can't figure out what the problem with my approach ist.</p>