Skip to content

BUG: pandas 1.1.0 introduces string comparison bug for larger datasets #35700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
Samreay opened this issue Aug 13, 2020 · 6 comments · Fixed by #36440
Closed
2 of 3 tasks

BUG: pandas 1.1.0 introduces string comparison bug for larger datasets #35700

Samreay opened this issue Aug 13, 2020 · 6 comments · Fixed by #36440
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@Samreay
Copy link

Samreay commented Aug 13, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd

# This works fine
df1 = pd.DataFrame({"a": [1,2,3], "b": ["x","y","z"]})
print(df1 == "x")

# Loading in some bigger data from Kaggle https://www.kaggle.com/dgomonov/new-york-city-airbnb-open-data
# data and code file included in zip to make it easy
df2 = pd.read_csv("AB_NYC_2019.csv")

# On pandas v1.1.0 throws a ValueError: unknown type str32
print(df2 == "x")

# On pandas v1.1.0 throws a ValueError: unknown type str128
print(df2 == "John")

reproduce.zip

Problem description

Previously comparing the dataframe to a string value would give a boolean mask as expected. It is now erroring. Confirmed that on v1.0.5 this works as expected, only on 1.1.0 does this error.

Expected Output

A boolean mask of true or false values with the same shape as the dataframe.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : d9fff27
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 49.3.1.post20200810
Cython : 0.29.21
pytest : 6.0.1
hypothesis : 5.24.0
sphinx : 3.2.0
blosc : None
feather : 0.4.0
xlsxwriter : None
lxml.etree : 4.4.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.0
xlrd : 1.2.0
xlwt : None
numba : None

@Samreay Samreay added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 13, 2020
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Aug 13, 2020

@Samreay thanks for the report! That's indeed a regression. You can also reproduce by expanding your dummy example to a larger dataset:

In [10]: df = pd.DataFrame({"a": [1,2,3]*10000, "b": ["x","y","z"]*10000})

In [11]: df == "x"  
...
ValueError: unknown type str32

@jorisvandenbossche jorisvandenbossche added Numeric Operations Arithmetic, Comparison, and Logical operations Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 13, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1.1 milestone Aug 13, 2020
@jorisvandenbossche
Copy link
Member

cc @jbrockmendel

@jbrockmendel
Copy link
Member

Yep, looks like we need to catch this in na_arithmetic_op

@TomAugspurger
Copy link
Contributor

@Samreay you might want to subscribe to pandas releases by "watching" the repo for "releases only". We make binaries available for release candidates so it should be easy to test and catch these issues before the release.

@simonjayhawkins
Copy link
Member

#32047

e6bd49f is the first bad commit
commit e6bd49f
Author: jbrockmendel [email protected]
Date: Wed Feb 26 04:53:45 2020 -0800

use numexpr for Series comparisons (#32047)

@simonjayhawkins
Copy link
Member

moved off 1.1.2 milestone (scheduled for this week) as no PRs to fix in the pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants