Description
Code Sample, a copy-pastable example if possible
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()
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