-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Inconsistent overflow behavior in Series.__setitem__ #53313
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
Interesting, if the null value in df23 is replaced with actual data, the overflow error is raised, so somehow the null is hiding the overflow error and causing an unsafe conversion to succeed. |
I tried running your example in the dev version of Pandas + pyarrow 12 and I got I then tried in pandas v.2.0.1 and got the error you describe. So this has been fixed in the dev version, but I don't see any entry on this in the whatsnew. INSTALLED VERSIONScommit : 855673f pandas : 2.1.0.dev0+808.g855673fdc5 |
Thanks @topper-123 for checking. Will this be part of pandas 2.0.2 or 2.1.0? |
v2.1. |
This is the PR that fixed it for reference. |
Closing as this will be fixed |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
An unsafe conversion succeeded. The first value of lhs is rounded when pyarrow should do safe conversions by default. Somehow, when I remove the 2nd row of the df, the expected error about an unsafe conversion is raised. I wouldn't expect the presence of a null value to hide an overflow error.
Expected Behavior
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\series.py", line 1209, in setitem
self._where(~key, value, inplace=True)
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\generic.py", line 9730, in _where
new_data = self._mgr.putmask(mask=cond, new=other, align=align)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\internals\managers.py", line 403, in putmask
return self.apply(
^^^^^^^^^^^
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\internals\managers.py", line 352, in apply
applied = getattr(b, f)(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\internals\blocks.py", line 1739, in putmask
values._putmask(mask, new)
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\arrays\base.py", line 1528, in _putmask
self[mask] = val
~~~~^^^^^^
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\arrays\arrow\array.py", line 1383, in setitem
data = self._replace_with_mask(self._data, key, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ca2_ps_311_0515\Lib\site-packages\pandas\core\arrays\arrow\array.py", line 1666, in _replace_with_mask
return pa.array(result, type=values.type, from_pandas=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pyarrow\array.pxi", line 323, in pyarrow.lib.array
File "pyarrow\array.pxi", line 83, in pyarrow.lib._ndarray_to_array
File "pyarrow\error.pxi", line 100, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Integer value -1291861603 is outside of the range exactly representable by a IEEE 754 single precision value
Installed Versions
INSTALLED VERSIONS
commit : 37ea63d
python : 3.11.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 7, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.0.1
numpy : 1.24.3
pytz : 2023.3
dateutil : 2.8.2
setuptools : 67.7.2
pip : 23.1.2
Cython : None
pytest : 7.0.1
hypothesis : None
sphinx : 4.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.13.2
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 12.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: