Skip to content

ValueError on df.columns.isin(pd.Series()) #16991

Closed
@wikiped

Description

@wikiped

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions