ValueError on df.columns.isin(pd.Series()) · Issue #16991 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
df = pd.DataFrame(columns=list('ab'))
s1 = pd.Series(['a'])
s2 = pd.Series()
df.columns.isin(s1)
df.columns.isin(s2)
Problem description
The second call to df.columns.isin(s2)
fails with
D:\Anaconda\envs\py3k\lib\site-packages\pandas\core\algorithms.py in <lambda>(x, y)
402 # work-around for numpy < 1.8 and comparisions on py3
403 # faster for larger cases to use np.in1d
--> 404 f = lambda x, y: htable.ismember_object(x, values)
405 if (_np_version_under1p8 and compat.PY3) or len(comps) > 1000000:
406 f = lambda x, y: np.in1d(x, y)
pandas\_libs\hashtable_func_helper.pxi in pandas._libs.hashtable.ismember_object (pandas\_libs\hashtable.c:30162)()
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'double'
Expected Output
array([ False, False], dtype=bool)
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
pandas: 0.20.3
numpy: 1.13.1
Might be linked to #16394