-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: "Python int too large" in maybe_convert_objects with numpy 1.26 #60023
Comments
I can confirm, but it seems working on main branch. |
Thanks. But do you mean the bug does not occur with the main branch of numpy, or do you mean the bug does not occur with the main branch of pandas and version 1.26.4 of numpy? As far as I've seen, this bug doesn't occur with the 2.x releases of numpy, only with the 1.x releases. I tried doing this:
And I also tried doing this:
Both installations exhibit the bug above. If you don't see the bug, what platform/interpreter and what versions of pandas and numpy are you using? |
It seems like this is an inconsistency in numpy. Looks like "weak promotion" in 2.x doesn't apply to comparisons, but "weak promotion" in 1.x does apply to comparisons?
In pandas, this causes an exception at either line 1457:
or line 2631:
for example:
|
I do not produce the bug on the main branch of pandas. My environment: INSTALLED VERSIONScommit : 49ca01b pandas : 3.0.0.dev0+1580.g68d9dcab5b.dirty |
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
pip install numpy==1.26.4 pandas==2.2.3
Issue Description
If using numpy 1.26, and numpy is set to "weak" or "weak_and_warn" promotion mode (meant to be compatible with the behavior of numpy 2.x), this causes internal pandas functions to fail.
For example, the above command to print a trivial DataFrame results in:
This doesn't happen with numpy 1.26 in its default "legacy" mode. It doesn't happen with numpy 2.x in either "legacy" or "weak" mode.
More information about numpy 1.x versus 2.x and promotion modes is documented here: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
Expected Behavior
print(pandas.DataFrame({"x": [1]}))
should not crash. It should work properly regardless of the global numpy promotion setting.Installed Versions
The text was updated successfully, but these errors were encountered: