<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; df = pd.DataFrame({'x': [1.], 'y': [2.], 'z': [3.]})
&gt;&gt;&gt; df.columns = ['x', 'x', 'z']
&gt;&gt;&gt; df[['x', 'y', 'z']]
KeyError: &quot;['z'] not in index&quot;"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</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-c1">&gt;&gt;</span><span class="pl-c1">&gt;</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-s">'x'</span>: [<span class="pl-c1">1.</span>], <span class="pl-s">'y'</span>: [<span class="pl-c1">2.</span>], <span class="pl-s">'z'</span>: [<span class="pl-c1">3.</span>]})
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>.<span class="pl-s1">columns</span> <span class="pl-c1">=</span> [<span class="pl-s">'x'</span>, <span class="pl-s">'x'</span>, <span class="pl-s">'z'</span>]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>[[<span class="pl-s">'x'</span>, <span class="pl-s">'y'</span>, <span class="pl-s">'z'</span>]]
<span class="pl-v">KeyError</span>: <span class="pl-s">"['z'] not in index"</span></pre></div>
<p dir="auto">I expected to see <code class="notranslate">KeyError: "['y'] not in index"</code>.</p>
<p dir="auto">I've tested this on the latest code in master (and on 0.16):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.18-400.1.1.el5
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB
LOCALE: None.None

pandas: 0.18.1+279.g31f8e4d
nose: None
pip: 1.3.1
setuptools: 0.6
Cython: 0.22
numpy: 1.9.2
scipy: None
statsmodels: None
xarray: None
IPython: 3.2.0-1
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.6
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.18-400.1.1.el5
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB
LOCALE: None.None

pandas: 0.18.1+279.g31f8e4d
nose: None
pip: 1.3.1
setuptools: 0.6
Cython: 0.22
numpy: 1.9.2
scipy: None
statsmodels: None
xarray: None
IPython: 3.2.0-1
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.6
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None
</code></pre></div>
<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="&gt;&gt;&gt; s = pd.Series([10,9,8,7,7,7,6])
&gt;&gt;&gt; s.nlargest(4)
0    10
1     9
2     8
3     7
dtype: int64"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-c1">10</span>,<span class="pl-c1">9</span>,<span class="pl-c1">8</span>,<span class="pl-c1">7</span>,<span class="pl-c1">7</span>,<span class="pl-c1">7</span>,<span class="pl-c1">6</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-en">nlargest</span>(<span class="pl-c1">4</span>)
<span class="pl-c1">0</span>    <span class="pl-c1">10</span>
<span class="pl-c1">1</span>     <span class="pl-c1">9</span>
<span class="pl-c1">2</span>     <span class="pl-c1">8</span>
<span class="pl-c1">3</span>     <span class="pl-c1">7</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">int64</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">The docstrings list <code class="notranslate">False</code> as one of the possible argument values for <code class="notranslate">keep</code>.  pandas raises a <code class="notranslate">ValueError</code> when attempting to use this parameter.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">It would be nice to have nlargest work like this.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; s.nlargest(4, keep=False)
0    10
1     9
2     8
3     7
4     7
5     7"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-en">nlargest</span>(<span class="pl-c1">4</span>, <span class="pl-s1">keep</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-c1">0</span>    <span class="pl-c1">10</span>
<span class="pl-c1">1</span>     <span class="pl-c1">9</span>
<span class="pl-c1">2</span>     <span class="pl-c1">8</span>
<span class="pl-c1">3</span>     <span class="pl-c1">7</span>
<span class="pl-c1">4</span>     <span class="pl-c1">7</span>
<span class="pl-c1">5</span>     <span class="pl-c1">7</span></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
# Paste the output here pd.show_versions() here
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.20.2<br>
pytest: 3.0.7<br>
pip: 9.0.1<br>
setuptools: 35.0.2<br>
Cython: 0.25.2<br>
numpy: 1.13.0<br>
scipy: 0.19.0<br>
xarray: None<br>
IPython: 6.0.0<br>
sphinx: 1.5.5<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: 1.2.0<br>
tables: 3.4.2<br>
numexpr: 2.6.2<br>
feather: None<br>
matplotlib: 2.0.2<br>
openpyxl: 2.4.7<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.3<br>
bs4: 4.6.0<br>
html5lib: 0.999999999<br>
sqlalchemy: 1.1.9<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: 0.3.0.post</p>
</details>