<p dir="auto">the following works quickly in 0.15.2 and has a performance issue on the last operation df.T.duplicated() in 0.16.0 and 0.16.1<br>
also on a private data set that works on 0.15.2 i get an error on 0.16.0 and 0.16.1 on the same operation.</p>
<p dir="auto">code:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas,numpy

df = pandas.DataFrame({'A': [1 for x in range(1000)],
                   'B': [1 for x in range(1000)]})

print (numpy.count_nonzero(df.duplicated()))
print (numpy.count_nonzero(df.T.duplicated()))

df = pandas.DataFrame({'A': [1 for x in range(1000000)],
                   'B': [1 for x in range(1000000)]})

print (numpy.count_nonzero(df.duplicated()))
print (numpy.count_nonzero(df.T.duplicated()))


this is the error i get on the private data set (code not reproduce yet with synthetic data):
  File &quot;C:\Anaconda3\lib\site-packages\pandas\util\decorators.py&quot;, line 88, in wrapper
    return func(*args, **kwargs)
  File &quot;C:\Anaconda3\lib\site-packages\pandas\core\frame.py&quot;, line 2867, in duplicated
    labels, shape = map(list, zip( * map(f, vals)))
  File &quot;C:\Anaconda3\lib\site-packages\pandas\core\frame.py&quot;, line 2856, in f
    labels, shape = factorize(vals, size_hint=min(len(self), _SIZE_HINT_LIMIT))
  File &quot;C:\Anaconda3\lib\site-packages\pandas\core\algorithms.py&quot;, line 135, in factorize
    labels = table.get_labels(vals, uniques, 0, na_sentinel)
  File &quot;pandas\hashtable.pyx&quot;, line 813, in pandas.hashtable.PyObjectHashTable.get_labels (pandas\hashtable.c:14025)
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span>,<span class="pl-s1">numpy</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-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1000</span>)],
                   <span class="pl-s">'B'</span>: [<span class="pl-c1">1</span> <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1000</span>)]})

<span class="pl-en">print</span> (<span class="pl-s1">numpy</span>.<span class="pl-en">count_nonzero</span>(<span class="pl-s1">df</span>.<span class="pl-en">duplicated</span>()))
<span class="pl-en">print</span> (<span class="pl-s1">numpy</span>.<span class="pl-en">count_nonzero</span>(<span class="pl-s1">df</span>.<span class="pl-v">T</span>.<span class="pl-en">duplicated</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-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1000000</span>)],
                   <span class="pl-s">'B'</span>: [<span class="pl-c1">1</span> <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1000000</span>)]})

<span class="pl-en">print</span> (<span class="pl-s1">numpy</span>.<span class="pl-en">count_nonzero</span>(<span class="pl-s1">df</span>.<span class="pl-en">duplicated</span>()))
<span class="pl-en">print</span> (<span class="pl-s1">numpy</span>.<span class="pl-en">count_nonzero</span>(<span class="pl-s1">df</span>.<span class="pl-v">T</span>.<span class="pl-en">duplicated</span>()))


<span class="pl-s1">this</span> <span class="pl-c1">is</span> <span class="pl-s1">the</span> <span class="pl-s1">error</span> <span class="pl-s1">i</span> <span class="pl-s1">get</span> <span class="pl-s1">on</span> <span class="pl-s1">the</span> <span class="pl-s1">private</span> <span class="pl-s1">data</span> <span class="pl-s1">set</span> (<span class="pl-s1">code</span> <span class="pl-c1">not</span> <span class="pl-s1">reproduce</span> <span class="pl-s1">yet</span> <span class="pl-k">with</span> <span class="pl-s1">synthetic</span> <span class="pl-s1">data</span>):
  <span class="pl-v">File</span> <span class="pl-s">"C:\Anaconda3\lib\site-packages\pandas\util\decorators.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">88</span>, <span class="pl-s1">in</span> <span class="pl-s1">wrapper</span>
    <span class="pl-s1">return</span> <span class="pl-en">func</span>(<span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"C:\Anaconda3\lib\site-packages\pandas\core<span class="pl-cce">\f</span>rame.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2867</span>, <span class="pl-s1">in</span> <span class="pl-s1">duplicated</span>
    <span class="pl-s1">labels</span>, <span class="pl-s1">shape</span> <span class="pl-c1">=</span> <span class="pl-en">map</span>(<span class="pl-s1">list</span>, <span class="pl-en">zip</span>( <span class="pl-c1">*</span> <span class="pl-en">map</span>(<span class="pl-s1">f</span>, <span class="pl-s1">vals</span>)))
  <span class="pl-v">File</span> <span class="pl-s">"C:\Anaconda3\lib\site-packages\pandas\core<span class="pl-cce">\f</span>rame.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2856</span>, <span class="pl-s1">in</span> <span class="pl-s1">f</span>
    <span class="pl-s1">labels</span>, <span class="pl-s1">shape</span> <span class="pl-c1">=</span> <span class="pl-en">factorize</span>(<span class="pl-s1">vals</span>, <span class="pl-s1">size_hint</span><span class="pl-c1">=</span><span class="pl-en">min</span>(<span class="pl-en">len</span>(<span class="pl-s1">self</span>), <span class="pl-s1">_SIZE_HINT_LIMIT</span>))
  <span class="pl-v">File</span> <span class="pl-s">"C:\Anaconda3\lib\site-packages\pandas\core<span class="pl-cce">\a</span>lgorithms.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">135</span>, <span class="pl-s1">in</span> <span class="pl-s1">factorize</span>
    <span class="pl-s1">labels</span> <span class="pl-c1">=</span> <span class="pl-s1">table</span>.<span class="pl-en">get_labels</span>(<span class="pl-s1">vals</span>, <span class="pl-s1">uniques</span>, <span class="pl-c1">0</span>, <span class="pl-s1">na_sentinel</span>)
  <span class="pl-v">File</span> <span class="pl-s">"pandas\hashtable.pyx"</span>, <span class="pl-s1">line</span> <span class="pl-c1">813</span>, <span class="pl-s1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">PyObjectHashTable</span>.<span class="pl-en">get_labels</span> (<span class="pl-s1">pandas</span>\h<span class="pl-s1">ashtable</span>.<span class="pl-s1">c</span>:<span class="pl-c1">14025</span>)
<span class="pl-v">ValueError</span>: <span class="pl-v">Buffer</span> <span class="pl-s1">has</span> <span class="pl-s1">wrong</span> <span class="pl-s1">number</span> <span class="pl-s1">of</span> <span class="pl-en">dimensions</span> (<span class="pl-s1">expected</span> <span class="pl-c1">1</span>, <span class="pl-s1">got</span> <span class="pl-c1">2</span>)</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="trange = pd.date_range(start=pd.Timestamp(year=2017, month=1, day=1), end=pd.Timestamp(year=2017, month=1, day=5))
# make a duplicate
trange = trange.insert(loc=5, item=pd.Timestamp(year=2017, month=1, day=5))

df = pd.DataFrame(0, index=trange, columns=[&quot;A&quot;, &quot;B&quot;])
bool_idx = np.array([True, False, False, False, False, True])
df.loc[trange[bool_idx], &quot;A&quot;] += 1"><pre class="notranslate"><span class="pl-s1">trange</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">date_range</span>(<span class="pl-s1">start</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s1">year</span><span class="pl-c1">=</span><span class="pl-c1">2017</span>, <span class="pl-s1">month</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">day</span><span class="pl-c1">=</span><span class="pl-c1">1</span>), <span class="pl-s1">end</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s1">year</span><span class="pl-c1">=</span><span class="pl-c1">2017</span>, <span class="pl-s1">month</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">day</span><span class="pl-c1">=</span><span class="pl-c1">5</span>))
<span class="pl-c"># make a duplicate</span>
<span class="pl-s1">trange</span> <span class="pl-c1">=</span> <span class="pl-s1">trange</span>.<span class="pl-en">insert</span>(<span class="pl-s1">loc</span><span class="pl-c1">=</span><span class="pl-c1">5</span>, <span class="pl-s1">item</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s1">year</span><span class="pl-c1">=</span><span class="pl-c1">2017</span>, <span class="pl-s1">month</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">day</span><span class="pl-c1">=</span><span class="pl-c1">5</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-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">trange</span>, <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">"A"</span>, <span class="pl-s">"B"</span>])
<span class="pl-s1">bool_idx</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">True</span>, <span class="pl-c1">False</span>, <span class="pl-c1">False</span>, <span class="pl-c1">False</span>, <span class="pl-c1">False</span>, <span class="pl-c1">True</span>])
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s1">trange</span>[<span class="pl-s1">bool_idx</span>], <span class="pl-s">"A"</span>] <span class="pl-c1">+=</span> <span class="pl-c1">1</span></pre></div>
<p dir="auto">Throws error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
&lt;ipython-input-32-b0e70145e9a6&gt; in &lt;module&gt;()
----&gt; 1 df.loc[trange[bool_idx], &quot;A&quot;] += 1

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
    176         else:
    177             key = com._apply_if_callable(key, self.obj)
--&gt; 178         indexer = self._get_setitem_indexer(key)
    179         self._setitem_with_indexer(indexer, value)
    180 

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _get_setitem_indexer(self, key)
    155         if isinstance(key, tuple):
    156             try:
--&gt; 157                 return self._convert_tuple(key, is_setter=True)
    158             except IndexingError:
    159                 pass

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_tuple(self, key, is_setter)
    222                 if i &gt;= self.obj.ndim:
    223                     raise IndexingError('Too many indexers')
--&gt; 224                 idx = self._convert_to_indexer(k, axis=i, is_setter=is_setter)
    225                 keyidx.append(idx)
    226         return tuple(keyidx)

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
   1228 
   1229                 mask = check == -1
-&gt; 1230                 if mask.any():
   1231                     raise KeyError('%s not in index' % objarr[mask])
   1232 

AttributeError: 'bool' object has no attribute 'any'
"><pre class="notranslate"><code class="notranslate">---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
&lt;ipython-input-32-b0e70145e9a6&gt; in &lt;module&gt;()
----&gt; 1 df.loc[trange[bool_idx], "A"] += 1

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
    176         else:
    177             key = com._apply_if_callable(key, self.obj)
--&gt; 178         indexer = self._get_setitem_indexer(key)
    179         self._setitem_with_indexer(indexer, value)
    180 

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _get_setitem_indexer(self, key)
    155         if isinstance(key, tuple):
    156             try:
--&gt; 157                 return self._convert_tuple(key, is_setter=True)
    158             except IndexingError:
    159                 pass

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_tuple(self, key, is_setter)
    222                 if i &gt;= self.obj.ndim:
    223                     raise IndexingError('Too many indexers')
--&gt; 224                 idx = self._convert_to_indexer(k, axis=i, is_setter=is_setter)
    225                 keyidx.append(idx)
    226         return tuple(keyidx)

/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
   1228 
   1229                 mask = check == -1
-&gt; 1230                 if mask.any():
   1231                     raise KeyError('%s not in index' % objarr[mask])
   1232 

AttributeError: 'bool' object has no attribute 'any'

</code></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">First I wasn't aware that I have a duplicated index in my code -- I only realised this when trying to reproduce the error in the example above. I used time index, because in my code I have a time index too.</p>
<p dir="auto">The problem is in <a href="https://github.com/pandas-dev/pandas/blob/793020293ee1e5fa023f45c12943a4ac51cc23d0/pandas/core/indexing.py#L1235">indexing.py  line 1235 and 1236</a>, where the variable <code class="notranslate">mask</code> is a python builtin <code class="notranslate">bool</code> (instead of a numpy array) and therefore does not support the method <code class="notranslate">.any() </code>.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">I am not sure if the code is legal with duplicates (I will filter duplicates in my code now). Nonetheless, I think a decent error message should be raised in such a case.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.8.0-58-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.20.1<br>
pytest: None<br>
pip: 9.0.1<br>
setuptools: 28.8.0<br>
Cython: None<br>
numpy: 1.13.1<br>
scipy: 0.19.1<br>
xarray: None<br>
IPython: 6.1.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.4.2<br>
numexpr: 2.6.2<br>
feather: None<br>
matplotlib: 2.0.2<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.9999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>