-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: modulo of pd.Int64Index returns negative values under some conditions #36526
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
Comments
@felixpatzelt Thanks a lot for the report, that's indeed a regression and wrong result .. It's not specific to Index, also a Series (or DataFrame) operation has the same issue:
|
I would like to work on this |
take |
@dishak331 Thanks! See also #35685 in case you might first want to find out which change caused the regression (sometimes that can be helpful) |
possibly duplicate of #36047 |
@jorisvandenbossche thanks! |
xref pydata/numexpr#365 |
okay so i just checked, this is a bug in Python itself. When we are doing -5%24 it is outputting as 19 instead of -5 |
@dishak331 No, it's not a bug in Python. Thats the defined behaviour of the modulo operation in Python 3. It's numexpr that is wrong here by applying C conventions into Python. |
oh okay okay @m1nde |
looks like the same PR responsible, #36047 (comment) first bad commit: [01623f8] CLN: Refactor pandas/tests/base - part3 (#30147) https://github.com/simonjayhawkins/pandas/runs/1150901284?check_suite_focus=true |
I think can close this as duplicate of #36047 |
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
Problem description
In Pandas 1.1.2, taking the modulo of an Int64Index can return negative values depending on the values in the index and on its length. This problem was not present in pandas 1.0.5. It is also inconsistent with the generally expected behaviour of modulo in python and numpy.
Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.7.5.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : 6.0.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : 0.10.1
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.2
fastparquet : None
gcsfs : None
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : None
xarray : 0.16.1
xlrd : None
xlwt : None
numba : 0.51.2
The text was updated successfully, but these errors were encountered: