擅长:python、mysql、java
<p>使用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.query.html" rel="nofollow noreferrer">^{<cd1>}</a>:</p>
<pre><code>df = df.query('y != y_pred').index
</code></pre>
<p>样品:</p>
^{pr2}$
<p>带有<a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow noreferrer">^{<cd2>}</a>的解决方案是:</p>
<pre><code>df1 = df[df.y != df.y_pred].index
print (df1)
Int64Index([599, 1069], dtype='int64')
</code></pre>
<p>或者另一个<a href="https://stackoverflow.com/a/43147280/2901002">answer</a>。在</p>
<p>对于检查不同的值:</p>
<pre><code>print (df.query('y != y_pred'))
y y_pred
599 0 1
1069 6 3
print (df[df.y != df.y_pred])
y y_pred
599 0 1
1069 6 3
</code></pre>