Skip to content

Comparison of categorical with tuple generates wrong results #18050

Closed
@yakupberk-sbg

Description

@yakupberk-sbg
import pandas as pd
s = pd.Series([(0, 0), (0, 1), (0, 0), (1, 0), (1, 1)])
s == (0, 0)
0     True
1    False
2     True
3    False
4    False
dtype: bool
s.astype('category') == (0, 0)
0    False
1    False
2    False
3    False
4    False
dtype: bool

Problem description

Result of s == (0, 0) and s.astype('category') == (0, 0) should be same if (0, 0) is a category.

Expected Output

s.astype('category') == (0, 0)
0     True
1    False
2     True
3    False
4    False
dtype: bool

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 17.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.21.0
pytest: 3.2.3
pip: 9.0.1
setuptools: 36.5.0
Cython: 0.26
numpy: 1.13.3
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: 1.6.3
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions