How to return the indices of maximum value from an array with python?
<p>I have an array and I want to find the indices of the maximum values.</p>

<p>For example:</p>

<pre><code>myarray = np.array([1,8,8,3,2])
</code></pre>

<p>I want to get the result: <code>[1,2]</code>, how can I do that?</p>

<p>(Actually I tried <code>np.argmax(myarray)</code>, but it only return the first occurrence <code>[1]</code>)</p>

<p>Given:</p>

<pre><code>&gt;&gt;&gt; myarray = np.array([1,8,8,3,2])
</code></pre>

<p>You can do:</p>

<pre><code>&gt;&gt;&gt; np.where(myarray==myarray[np.argmax(myarray)])
(array([1, 2]),)
</code></pre>

<p>or, </p>

<pre><code>&gt;&gt;&gt; np.where(myarray==max(myarray))
(array([1, 2]),)
</code></pre>

<p>or, </p>

<pre><code>&gt;&gt;&gt; np.nonzero(myarray==max(myarray))
(array([1, 2]),)
</code></pre>

python numpy