Repository: pandas-dev/pandas

Issue:
Error with .drop([]) on non-unique index
#### Code Sample, a copy-pastable example if possible

```python
In [2]: pd.DataFrame([[1,2], [3,4], [5,6]], index=['a','a','b']).drop(['a'])
Out[2]: 
   0  1
b  5  6

In [3]: pd.DataFrame([[1,2], [3,4], [5,6]], index=['a','a','b']).drop(['b'])
Out[3]: 
   0  1
a  1  2
a  3  4

In [4]: pd.DataFrame([[1,2], [3,4], [5,6]], index=['a','a','b']).drop([])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-ae217de2434b> in <module>()
----> 1 pd.DataFrame([[1,2], [3,4], [5,6]], index=['a','a','b']).drop([])

/home/pietro/.local/lib/python3.5/site-packages/pandas/core/generic.py in drop(self, labels, axis, level, inplace, errors)
   2063                 indexer = ~axis.get_level_values(level).isin(labels)
   2064             else:
-> 2065                 indexer = ~axis.isin(labels)
   2066 
   2067             slicer = [slice(None)] * self.ndim

/home/pietro/.local/lib/python3.5/site-packages/pandas/core/indexes/base.py in isin(self, values, level)
   2766         if level is not None:
   2767             self._validate_index_level(level)
-> 2768         return algos.isin(np.array(self), values)
   2769 
   2770     def _can_reindex(self, indexer):

/home/pietro/.local/lib/python3.5/site-packages/pandas/core/algorithms.py in isin(comps, values)
    419             comps = comps.astype(object)
    420 
--> 421     return f(comps, values)
    422 
    423 

/home/pietro/.local/lib/python3.5/site-packages/pandas/core/algorithms.py in <lambda>(x, y)
    397     # work-around for numpy < 1.8 and comparisions on py3
    398     # faster for larger cases to use np.in1d
--> 399     f = lambda x, y: htable.ismember_object(x, values)
    400     if (_np_version_under1p8 and compat.PY3) or len(comps) > 1000000:
    401         f = lambda x, y: np.in1d(x, y)

/home/pietro/nobackup/repo/pandas/pandas/_libs/hashtable_func_helper.pxi in pandas._libs.hashtable.ismember_object (pandas/_libs/hashtable.c:29677)()

ValueError: Buffer dtype mismatch, expected 'Python object' but got 'double'



```
#### Problem description

Notice ``pd.DataFrame([[1,2], [3,4], [5,6]], index=['a','b', 'c']).drop([])`` works just fine.

#### Expected Output

Just the original ``DataFrame``.

#### Output of ``pd.show_versions()``

<details>


INSTALLED VERSIONS
------------------
commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.7.0-1-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: it_IT.utf8
LOCALE: it_IT.UTF-8

pandas: 0.20.1
pytest: 3.0.6
pip: 9.0.1
setuptools: None
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: 0.9.2
IPython: 5.1.0.dev
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.6.1
feather: 0.3.1
matplotlib: 2.0.2
openpyxl: 2.3.0
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.6
lxml: 3.7.1
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.0.15
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 0.2.1


</details>



Discussion:
Working on this as a part of the pycon sprint

Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -12,6 +12,7 @@
 from pandas._libs import tslib, lib
 from pandas.core.dtypes.common import (
     _ensure_int64,
+    _ensure_object,
     needs_i8_conversion,
     is_scalar,
     is_number,
@@ -2076,7 +2077,7 @@ def drop(self, labels, axis=0, level=None, inplace=False, errors='raise'):
             result = dropped
 
         else:
-            labels = com._index_labels_to_array(labels)
+            labels = _ensure_object(com._index_labels_to_array(labels))
             if level is not None:
                 if not isinstance(axis, MultiIndex):
                     raise AssertionError('axis must be a MultiIndex')


Test patch:
diff --git a/pandas/tests/frame/test_axis_select_reindex.py b/pandas/tests/frame/test_axis_select_reindex.py
--- a/pandas/tests/frame/test_axis_select_reindex.py
+++ b/pandas/tests/frame/test_axis_select_reindex.py
@@ -61,6 +61,11 @@ def test_drop_names(self):
         expected = Index(['e', 'f'], name='second')
         tm.assert_index_equal(dropped.columns, expected)
 
+        # GH 16398
+        dropped = df.drop([], errors='ignore')
+        expected = Index(['a', 'b', 'c'], name='first')
+        tm.assert_index_equal(dropped.index, expected)
+
     def test_drop_col_still_multiindex(self):
         arrays = [['a', 'b', 'c', 'top'],
                   ['', '', '', 'OD'],
@@ -100,6 +105,7 @@ def test_drop(self):
                           columns=['a', 'a', 'b'])
         assert_frame_equal(nu_df.drop('a', axis=1), nu_df[['b']])
         assert_frame_equal(nu_df.drop('b', axis='columns'), nu_df['a'])
+        assert_frame_equal(nu_df.drop([]), nu_df)  # GH 16398
 
         nu_df = nu_df.set_index(pd.Index(['X', 'Y', 'X']))
         nu_df.columns = list('abc')