Pandas max value index
<p>I have a Pandas DataFrame with a mix of screen names, tweets, fav's etc.  I want find the max value of 'favcount' (which i have already done) and also return the screen name of that 'tweet'</p>

<pre><code>df = pd.DataFrame()
df['timestamp'] = timestamp
df['sn'] = sn
df['text'] = text
df['favcount'] = fav_count


print df
print '------'
print df['favcount'].max()
</code></pre>

<p>I cant seem to find anything on this, can anyone help guide me in the right direction?</p>

<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.idxmax.html" rel="nofollow"><code>idxmax</code></a> - get index of max value of <code>favcount</code> and then select value in column <code>sn</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a>:</p>

<pre><code>df = pd.DataFrame({'favcount':[1,2,3], 'sn':['a','b','c']})

print (df)
   favcount sn
0         1  a
1         2  b
2         3  c

print (df.favcount.idxmax())
2

print (df.ix[df.favcount.idxmax()])
favcount    3
sn          c
Name: 2, dtype: object

print (df.ix[df.favcount.idxmax(), 'sn'])
c
</code></pre>

python pandas twitter indexing max