In numpy, Python, how to conditionally rewrite part of an array, when the values I want to set are in an array of a different size?
<p>Let's say I have three arrays:</p>

<pre><code>A[size1] of {0..size1}
B[size2] of {0..size1}
C[size2] of boolean
</code></pre>

<p>What I want:</p>

<pre><code>for (int e = 0; e &lt; size2; ++e) :
    if C[e] == some_condition, then B[e] = A[B[e]]
</code></pre>

<p>Since Python is slow, I have to implement it via numpy arithmetic on arrays. How can I do that?</p>

<p>Example:</p>

<pre><code>A = np.array([np.random.randint(0,n,size1), np.random.randint(0,size1,size1)])
B = np.random.randint(0,size1,size2)
C = np.random.randint(0,n,size2)

#that's the part I want to do in numpy:
for i in range (size2) :
    if (C[i] &gt; A[0][B[i]]) : 
        B[i] = A[1][B[i]]
</code></pre>