<p dir="auto">cf <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="10120999" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/2706" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/2706/hovercard" href="https://github.com/pandas-dev/pandas/issues/2706">#2706</a></p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Your code here

df = pandas.DataFrame({'a': [1, 10, 8, 11, -1],
                'b': [1.0, 2.0, 3.0, 3.0, 4.0]})
df.nlargest(3, 'b')
Result:
	a	b
4	-1	4.0
2	8	3.0
3	11	3.0
2	8	3.0
3	11	3.0"><pre class="notranslate"><span class="pl-c"># Your code here</span>

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'a'</span>: [<span class="pl-c1">1</span>, <span class="pl-c1">10</span>, <span class="pl-c1">8</span>, <span class="pl-c1">11</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>],
                <span class="pl-s">'b'</span>: [<span class="pl-c1">1.0</span>, <span class="pl-c1">2.0</span>, <span class="pl-c1">3.0</span>, <span class="pl-c1">3.0</span>, <span class="pl-c1">4.0</span>]})
<span class="pl-s1">df</span>.<span class="pl-en">nlargest</span>(<span class="pl-c1">3</span>, <span class="pl-s">'b'</span>)
<span class="pl-v">Result</span>:
	<span class="pl-s1">a</span>	<span class="pl-s1">b</span>
<span class="pl-c1">4</span>	<span class="pl-c1">-</span><span class="pl-c1">1</span>	<span class="pl-c1">4.0</span>
<span class="pl-c1">2</span>	<span class="pl-c1">8</span>	<span class="pl-c1">3.0</span>
<span class="pl-c1">3</span>	<span class="pl-c1">11</span>	<span class="pl-c1">3.0</span>
<span class="pl-c1">2</span>	<span class="pl-c1">8</span>	<span class="pl-c1">3.0</span>
<span class="pl-c1">3</span>	<span class="pl-c1">11</span>	<span class="pl-c1">3.0</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">[this should explain <strong>why</strong> the current behaviour is a problem and why the expected output is a better solution.]</p>
<p dir="auto">Duplicate values in column 'b' is not being handled correctly. The result is different than<br>
what "df.sort_values('b', ascending=False).head(3)" produces.</p>
<p dir="auto"><strong>Note</strong>: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!</p>
<p dir="auto"><strong>Note</strong>: Many problems can be resolved by simply upgrading <code class="notranslate">pandas</code> to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check if <code class="notranslate">master</code> addresses this issue, but that is not necessary.</p>
<p dir="auto">For documentation-related issues, you can check the latest versions of the docs on <code class="notranslate">master</code> here:</p>
<p dir="auto"><a href="https://pandas-docs.github.io/pandas-docs-travis/" rel="nofollow">https://pandas-docs.github.io/pandas-docs-travis/</a></p>
<p dir="auto">If the issue has not been resolved there, go ahead and file it in the issue tracker.</p>
<h4 dir="auto">Expected Output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" a	b"><pre class="notranslate"><code class="notranslate"> a	b
</code></pre></div>
<p dir="auto">4	-1	4.0<br>
2	8	3.0<br>
3	11	3.0</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.12.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.3.5-smp-808.15.0.0<br>
machine: x86_64<br>
processor:<br>
byteorder: little<br>
LC_ALL: en_US.UTF-8<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.19.2<br>
nose: None<br>
pip: None<br>
setuptools: None<br>
Cython: None<br>
numpy: 1.11.1<br>
scipy: 0.15.1<br>
statsmodels: 0.6.1<br>
xarray: None<br>
IPython: 2.0.0<br>
sphinx: None<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.1.1<br>
numexpr: 2.5<br>
matplotlib: 1.5.2<br>
openpyxl: None<br>
xlrd: 0.9.3<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 1.0b8<br>
httplib2: 0.9.2<br>
apiclient: 1.5.5<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8<br>
boto: None<br>
pandas_datareader: None</p>
<p dir="auto">[paste the output of <code class="notranslate">pd.show_versions()</code> here below this line]</p>