How to compare two rows of two pandas series?
<p>I have two python pandas series <code>df10</code> and <code>df5</code>. I want to compare their values.For example: <code>df10[-1:]&lt; df5[-1:]</code> ,it returns true. <code>df10[-2:-1] &gt; df5[-2:-1]</code> , it returns false.</p>

<p>But if I combine them together, <code>df10[-1:]&lt; df5[-1:] and df10[-2:-1]&gt;df5[-2:-1]</code>,it returns </p>

<blockquote>
  <p>The truth value of a Series is ambiguous. Use a.empty, a.bool(),
  a.item(), a.any() or a.all()</p>
</blockquote>

<p>But I expect it returns false. How can I solve this problem?</p>

<p>You can do this with the pandas Series <code>values</code> attribute:</p>

<pre><code>if (df10.values[-2:-1] &gt; df5.values[-2:-1]) and\ 
        (df10.values[-1:] &lt; df5.values[-1:]):
    print("we met the conditions!")
</code></pre>

python pandas