擅长:python、mysql、java
<p>我们可以用<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.searchsorted.html" rel="nofollow noreferrer">^{<cd1>}</a>-</p>
<pre><code>In [43]: out[np.searchsorted(ind,a)]
Out[43]:
array([[9, 8, 7],
[6, 5, 4],
[3, 2, 1]])
</code></pre>
<p>对于<code>ind</code>不一定排序的一般情况,我们需要使用<code>sorter</code>arg-</p>
<pre><code>In [44]: sidx = ind.argsort()
In [45]: out[sidx[np.searchsorted(ind,a,sorter=sidx)]]
Out[45]:
array([[9, 8, 7],
[6, 5, 4],
[3, 2, 1]])
</code></pre>