Skip to content

BUG: ensure to_numeric down-casts to uint64 for large unsigned integers #61766

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

to_numeric(..., downcast="unsigned") failed to honour the requested
uint64 dtype when values exceeded np.iinfo(np.int64).max, returning
float64 instead and losing integer precision (GH #14422 /
test_downcast_uint64).
Added a fallback that detects integral, non-negative float results and
safely casts them to np.uint64. All existing logic remains unchanged
for other code paths; the previously xfailed test now passes.

# parsing large Python ints), attempt a direct cast to uint64 as a
# last resort. This addresses GH#14422 where `to_numeric` failed to
# downcast `[0, 9223372036854775808]` to ``uint64``.
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you investigate why this isn't being done in maybe_downcast_numeric instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants