擅长:python、mysql、java
<p>使用<a href="http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#the-query-method" rel="noreferrer">.query()</a>方法的替代解决方案:</p>
<pre><code>In [5]: df.query("countries in @countries")
Out[5]:
countries
1 UK
3 China
In [6]: df.query("countries not in @countries")
Out[6]:
countries
0 US
2 Germany
</code></pre>