-
-
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/API: setting behavior inserting negative numbers in np.uint/nullable UInt Series #48867
Comments
Isn’t the setting behavior similar to when you set a float into an integer column? Eg we try to find a common dtype |
Ah yeah that's analogous behavior. Here's I'm pointing out the inconsistency between non-nullable and nullable uint and what @seberg is considering in the future for NEP 50. |
At this point, I actually don't care much about what we do here in NumPy (which may be my problem). Doing it should simplify the code/logic in the long term, though ;). If pandas typically (or even sometimes) has the behavior of promoting columns on insertion then it would seem to me that an error in NumPy is preferable over doing the unsafe cast (from a pandas perspective at least). |
The inconsistency on our side is a bit related to #47577 too. |
I think this is biting us downstream now that NEP 50 is implemented in numpy 2.0.dev. Example log: https://github.com/spacetelescope/jdaviz/actions/runs/6643820714/job/18051683584 (that is a lot to read through so I repeated the relevant bits below)
pandas/pandas/core/dtypes/cast.py Line 612 in 074ab2f
|
Thanks for the report. Addressing this in #55707 and will hopefully get this in today |
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
Numpy currently returns an overflowed valued but may raise in the future with NEP 50 cc @seberg
Series with np.uint appears to upcast the type to support -1
Series with nullable UInt appears to return an overflowed value
Here are the corresponding construction behavior
Expected Behavior
Not sure if the existing rules here are established, but maybe given construction raises shouldn't setting too?
Installed Versions
Numpy Version: '1.23.1'
The text was updated successfully, but these errors were encountered: