擅长:python、mysql、java
<p>从<code>pandas</code>文档中:</p>
<blockquote>
<p>DataFrame.loc</p>
<p>Access a group of rows and columns by label(s) or a boolean array.
.loc[] is primarily label based, but may also be used with a boolean array.
Allowed inputs are:</p>
<ul>
<li><p>A single label, e.g. 5 or 'a', (note that 5 is interpreted as a label of the index, and never as an integer position along the
index).</p></li>
<li><p>A list or array of labels, e.g. ['a', 'b', 'c'].</p></li>
<li><p>A slice object with labels, e.g. 'a':'f'.</p></li>
<li><p>A boolean array of the same length as the axis being sliced, e.g. [True, False, True].</p></li>
<li>A callable function with one argument (the calling Series, DataFrame or Panel) and that returns valid output for indexing (one of
the above)</li>
</ul>
</blockquote>
<p>因为我猜<code>ii</code>是整数类型,所以您需要使用<code>df.iloc</code>来代替:</p>
<pre><code>A = (data.iloc[ii] >= A1) & (data.iloc[ii] < A2)
</code></pre>