<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="In []:
df = pd.DataFrame({'test':1, 1:2, 2:3}, index=[0])
df.loc[:, 'test':]
Out[]:
   test  1  2
0     1  2  3

In []:
df.loc[:, 1:]
Out[]:
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-655-3b97c047dcab&gt; in &lt;module&gt;()
      1 df = pd.DataFrame({'test':1, 1:2, 2:3}, index=[0])
----&gt; 2 df.loc[:, 1:]
[snip]
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/indexes/base.py in _invalid_indexer(self, form, key)
   1574                         &quot;indexers [{key}] of {kind}&quot;.format(
   1575                             form=form, klass=type(self), key=key,
-&gt; 1576                             kind=type(key)))
   1577 
   1578     def get_duplicates(self):

TypeError: cannot do slice indexing on &lt;class 'pandas.core.indexes.base.Index'&gt; with these indexers [1] of &lt;class 'int'&gt;

In []:
df = pd.DataFrame({0:1, 1:2, 2:3}, index=[0])
df.loc[:, 1:]
Out[]:
   1  2
0  2  3"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-s1"></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">'test'</span>:<span class="pl-c1">1</span>, <span class="pl-c1">1</span>:<span class="pl-c1">2</span>, <span class="pl-c1">2</span>:<span class="pl-c1">3</span>}, <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>])
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[:, <span class="pl-s">'test'</span>:]
<span class="pl-v">Out</span>[]:
   <span class="pl-s1">test</span>  <span class="pl-c1">1</span>  <span class="pl-c1">2</span>
<span class="pl-c1">0</span>     <span class="pl-c1">1</span>  <span class="pl-c1">2</span>  <span class="pl-c1">3</span>

<span class="pl-v">In</span> []:
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[:, <span class="pl-c1">1</span>:]
<span class="pl-v">Out</span>[]:
<span class="pl-v">TypeError</span>                                 <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">655</span><span class="pl-c1">-</span><span class="pl-c1">3</span><span class="pl-s1">b97c047dcab</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
      <span class="pl-c1">1</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">'test'</span>:<span class="pl-c1">1</span>, <span class="pl-c1">1</span>:<span class="pl-c1">2</span>, <span class="pl-c1">2</span>:<span class="pl-c1">3</span>}, <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>])
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2</span> <span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[:, <span class="pl-c1">1</span>:]
[<span class="pl-s1">snip</span>]
<span class="pl-c1">/</span><span class="pl-v">Library</span><span class="pl-c1">/</span><span class="pl-v">Frameworks</span><span class="pl-c1">/</span><span class="pl-v">Python</span>.<span class="pl-s1">framework</span><span class="pl-c1">/</span><span class="pl-v">Versions</span><span class="pl-c1">/</span><span class="pl-c1">3.6</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python3</span>.<span class="pl-c1">6</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">indexes</span><span class="pl-c1">/</span><span class="pl-s1">base</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_invalid_indexer</span>(<span class="pl-s1">self</span>, <span class="pl-s1">form</span>, <span class="pl-s1">key</span>)
   <span class="pl-c1">1574</span>                         <span class="pl-s">"indexers [{key}] of {kind}"</span>.<span class="pl-en">format</span>(
   <span class="pl-c1">1575</span>                             <span class="pl-s1">form</span><span class="pl-c1">=</span><span class="pl-s1">form</span>, <span class="pl-s1">klass</span><span class="pl-c1">=</span><span class="pl-en">type</span>(<span class="pl-s1">self</span>), <span class="pl-s1">key</span><span class="pl-c1">=</span><span class="pl-s1">key</span>,
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1576</span>                             <span class="pl-s1">kind</span><span class="pl-c1">=</span><span class="pl-en">type</span>(<span class="pl-s1">key</span>)))
   <span class="pl-c1">1577</span> 
   <span class="pl-c1">1578</span>     <span class="pl-k">def</span> <span class="pl-en">get_duplicates</span>(<span class="pl-s1">self</span>):

<span class="pl-v">TypeError</span>: <span class="pl-s1">cannot</span> <span class="pl-s1">do</span> <span class="pl-s1">slice</span> <span class="pl-s1">indexing</span> <span class="pl-s1">on</span> <span class="pl-c1">&lt;</span><span class="pl-s1">class</span> <span class="pl-s">'pandas.core.indexes.base.Index'</span><span class="pl-c1">&gt;</span> <span class="pl-s1">with</span> <span class="pl-s1">these</span> <span class="pl-s1">indexers</span> [<span class="pl-c1">1</span>] <span class="pl-s1">of</span> <span class="pl-c1">&lt;</span><span class="pl-s1">class</span> <span class="pl-s">'int'</span><span class="pl-c1">&gt;</span>

<span class="pl-v">In</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-c1">0</span>:<span class="pl-c1">1</span>, <span class="pl-c1">1</span>:<span class="pl-c1">2</span>, <span class="pl-c1">2</span>:<span class="pl-c1">3</span>}, <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>])
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[:, <span class="pl-c1">1</span>:]
<span class="pl-v">Out</span>[]:
   <span class="pl-c1">1</span>  <span class="pl-c1">2</span>
<span class="pl-c1">0</span>  <span class="pl-c1">2</span>  <span class="pl-c1">3</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.]<br>
When having a columns with mixed types, e.g. <code class="notranslate">&lt;str&gt;, &lt;int&gt;</code> any slicing using the <code class="notranslate">int</code> columns causes a <code class="notranslate">ValueError</code>.</p>
<p dir="auto">When you have just <code class="notranslate">int</code> columns slicing by <code class="notranslate">int</code> does not cause an issue.</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>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">[paste the output of <code class="notranslate">pd.show_versions()</code> here below this line]<br>
INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.1.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 17.5.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.22.0<br>
pytest: 3.2.2<br>
pip: 10.0.1<br>
setuptools: 39.0.1<br>
Cython: 0.28.1<br>
numpy: 1.14.2<br>
scipy: 1.0.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.2.1<br>
sphinx: 1.7.2<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2018.4<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 2.2.2<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: 1.3.0<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.6.0<br>
html5lib: 0.9999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: 0.6.0</p>
</details>
<p dir="auto">How would people feel about me adding a "select_all" option to duplicates / duplicated that returns all duplicated rows, not just all but first or all but last?</p>
<p dir="auto">I often check to see if I have duplicates by some primary key, and if I do, I then want to look at ALL rows with the same primary key. Right now, duplicates / duplicated won't do so and I need to use the following hack:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df[df.duplicated('key',take_last=True) | df.duplicated('key')]"><pre class="notranslate"><code class="notranslate">df[df.duplicated('key',take_last=True) | df.duplicated('key')]
</code></pre></div>
<p dir="auto">It seems I"m not the only person with this issue:<br>
<a href="http://stackoverflow.com/questions/26244309/how-to-analyze-all-duplicate-entries-in-this-pandas-dataframe" rel="nofollow">http://stackoverflow.com/questions/26244309/how-to-analyze-all-duplicate-entries-in-this-pandas-dataframe</a><br>
<a href="http://stackoverflow.com/questions/14657241/how-do-i-get-a-list-of-all-the-duplicate-items-using-pandas-in-python" rel="nofollow">http://stackoverflow.com/questions/14657241/how-do-i-get-a-list-of-all-the-duplicate-items-using-pandas-in-python</a><br>
<a href="http://stackoverflow.com/questions/23667369/drop-all-duplicate-rows-in-python-pandas" rel="nofollow">http://stackoverflow.com/questions/23667369/drop-all-duplicate-rows-in-python-pandas</a></p>
<p dir="auto">Happy to write PR if people support.</p>