<p dir="auto">With pandas version 0.12:<br>
In [3]: pandas.version.version<br>
Out[3]: '0.12.0'</p>
<h2 dir="auto">Code to reproduce:</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import collections
import pandas as pd
import numpy as np

cols = map(str, np.unique(np.random.randint(0, 1000000, 200)))
index = map(str, np.unique(np.random.randint(0, 1000000, 5000)))
df = pd.DataFrame(np.random.randint(0,5,(len(index), len(cols))),
                  index=index, columns=cols)

types = []
for _ in xrange(1000):
    subcols = np.random.choice(cols, 10)
    subindex = np.random.choice(index, 400)
    t = df.loc[subindex, subcols]
    if type(t[subcols[0]]) == pd.core.series.Series:
        types.append('Series')
    elif type(t[subcols[0]]) == pd.core.frame.DataFrame:
        types.append('Frame')
    else:
        raise Exception()

print collections.Counter(types)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">collections</span>
<span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">cols</span> <span class="pl-c1">=</span> <span class="pl-en">map</span>(<span class="pl-s1">str</span>, <span class="pl-s1">np</span>.<span class="pl-en">unique</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>, <span class="pl-c1">1000000</span>, <span class="pl-c1">200</span>)))
<span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-en">map</span>(<span class="pl-s1">str</span>, <span class="pl-s1">np</span>.<span class="pl-en">unique</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>, <span class="pl-c1">1000000</span>, <span class="pl-c1">5000</span>)))
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randint</span>(<span class="pl-c1">0</span>,<span class="pl-c1">5</span>,(<span class="pl-en">len</span>(<span class="pl-s1">index</span>), <span class="pl-en">len</span>(<span class="pl-s1">cols</span>))),
                  <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">index</span>, <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-s1">cols</span>)

<span class="pl-s1">types</span> <span class="pl-c1">=</span> []
<span class="pl-k">for</span> <span class="pl-s1">_</span> <span class="pl-c1">in</span> <span class="pl-en">xrange</span>(<span class="pl-c1">1000</span>):
    <span class="pl-s1">subcols</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">choice</span>(<span class="pl-s1">cols</span>, <span class="pl-c1">10</span>)
    <span class="pl-s1">subindex</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">choice</span>(<span class="pl-s1">index</span>, <span class="pl-c1">400</span>)
    <span class="pl-s1">t</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s1">subindex</span>, <span class="pl-s1">subcols</span>]
    <span class="pl-k">if</span> <span class="pl-en">type</span>(<span class="pl-s1">t</span>[<span class="pl-s1">subcols</span>[<span class="pl-c1">0</span>]]) <span class="pl-c1">==</span> <span class="pl-s1">pd</span>.<span class="pl-s1">core</span>.<span class="pl-s1">series</span>.<span class="pl-v">Series</span>:
        <span class="pl-s1">types</span>.<span class="pl-en">append</span>(<span class="pl-s">'Series'</span>)
    <span class="pl-k">elif</span> <span class="pl-en">type</span>(<span class="pl-s1">t</span>[<span class="pl-s1">subcols</span>[<span class="pl-c1">0</span>]]) <span class="pl-c1">==</span> <span class="pl-s1">pd</span>.<span class="pl-s1">core</span>.<span class="pl-s1">frame</span>.<span class="pl-v">DataFrame</span>:
        <span class="pl-s1">types</span>.<span class="pl-en">append</span>(<span class="pl-s">'Frame'</span>)
    <span class="pl-k">else</span>:
        <span class="pl-k">raise</span> <span class="pl-v">Exception</span>()

<span class="pl-k">print</span> <span class="pl-s1">collections</span>.<span class="pl-v">Counter</span>(<span class="pl-s1">types</span>)</pre></div>
<hr>
<p dir="auto">About 20% of the time the result is a DataFrame and the other 80% is a Series</p>
<p dir="auto">I don't <em>think</em> there is a way to get the nlargest elements in a DataFrame without sorting.</p>
<p dir="auto">In ordinary python you'd use heapq's nlargest (and we can hack a bit to use it for a DataFrame):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [10]: df
Out[10]:
                IP                                              Agent  Count
0    74.86.158.106  Mozilla/5.0+(compatible; UptimeRobot/2.0; http...    369
1   203.81.107.103  Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20...    388
2  173.199.120.155  Mozilla/5.0 (compatible; AhrefsBot/4.0; +http:...    417
3    124.43.84.242  Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.3...    448
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...    454
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...    461
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...    467

In [11]: df.sort('Count', ascending=False).head(3)
Out[11]:
                IP                                              Agent  Count
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...    467
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...    461
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...    454"><pre class="notranslate"><code class="notranslate">In [10]: df
Out[10]:
                IP                                              Agent  Count
0    74.86.158.106  Mozilla/5.0+(compatible; UptimeRobot/2.0; http...    369
1   203.81.107.103  Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20...    388
2  173.199.120.155  Mozilla/5.0 (compatible; AhrefsBot/4.0; +http:...    417
3    124.43.84.242  Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.3...    448
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...    454
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...    461
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...    467

In [11]: df.sort('Count', ascending=False).head(3)
Out[11]:
                IP                                              Agent  Count
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...    467
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...    461
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...    454
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [21]: from heapq import nlargest

In [22]: top_3 = nlargest(3, df.iterrows(), key=lambda x: x[1]['Count'])

In [23]: pd.DataFrame.from_items(top_3).T
Out[23]:
                IP                                              Agent Count
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...   467
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...   461
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...   454"><pre class="notranslate"><code class="notranslate">In [21]: from heapq import nlargest

In [22]: top_3 = nlargest(3, df.iterrows(), key=lambda x: x[1]['Count'])

In [23]: pd.DataFrame.from_items(top_3).T
Out[23]:
                IP                                              Agent Count
6   124.43.104.198  Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20...   467
5   124.43.155.138  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) G...   461
4  112.135.196.223  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.3...   454
</code></pre></div>
<p dir="auto">This is much slower than sorting, presumbly from the overhead, I thought I'd throw this as a feature idea anyway.</p>
<p dir="auto">see <a href="http://stackoverflow.com/a/17194717/1240268" rel="nofollow">http://stackoverflow.com/a/17194717/1240268</a></p>