python pandas - identify row of rolling maximum value from panel?
<p>Does Panel have anything like pan.idxmax(axis='items') which could return the row # or index for the largest value as in the question linked below which piRSquared answered perfectly? </p>

<p><a href="http://stackoverflow.com/questions/40000718/python-pandas-possible-to-compare-3-dfs-of-same-shape-using-wheremax-is-thi">Link to original question</a></p>

<p>Thanks!</p>

<p>consider the <code>pd.Panel</code> <code>p</code></p>

<pre><code>dfs = dict(
    one=pd.DataFrame(np.random.randint(1, 10, (5, 5))),
    two=pd.DataFrame(np.random.randint(1, 10, (5, 5))),
    three=pd.DataFrame(np.random.randint(1, 10, (5, 5))),
)

p = pd.Panel(dfs)
p.to_frame().unstack()
</code></pre>

<p><a href="https://i.stack.imgur.com/i5lzc.png" rel="nofollow"><img src="https://i.stack.imgur.com/i5lzc.png" alt="enter image description here"></a></p>

<hr>

<p>the <code>pd.Panel</code> object doesn't have an <code>idxmax</code> method.  But the underlying numpy array does have the <code>argmax</code> method.  I've built this custom function to leverage that.</p>

<pre><code>def idxmax(pn, axis=0):
    indices = pd.Series(['items', 'major_axis', 'minor_axis'])
    idx, col = indices.drop(axis)
    return pd.DataFrame(pn.values.argmax(axis),
                        pn.__getattribute__(idx),
                        pn.__getattribute__(col))
</code></pre>

<hr>

<p><strong><em>usage</em></strong>  </p>

<pre><code>idxmax(p, 0)
</code></pre>

<p><a href="https://i.stack.imgur.com/yv19F.png" rel="nofollow"><img src="https://i.stack.imgur.com/yv19F.png" alt="enter image description here"></a></p>

<pre><code>idxmax(p, 1)
</code></pre>

<p><a href="https://i.stack.imgur.com/g6DCM.png" rel="nofollow"><img src="https://i.stack.imgur.com/g6DCM.png" alt="enter image description here"></a></p>

<pre><code>idxmax(p, 2)
</code></pre>

<p><a href="https://i.stack.imgur.com/Yj7QL.png" rel="nofollow"><img src="https://i.stack.imgur.com/Yj7QL.png" alt="enter image description here"></a></p>

python pandas max panel vectorization