-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
IntegerArray + List returns ndarray #22962
Comments
A possible solution would be to first try to convert the list to an IntegerArray, and only if that fails to an np.ndarray. So that would ensure that the list with integers / NaNs becomes IntegerArray, and thus the result will also be one. But a disadvantage of that is that then something like |
Yeah, the round float case is unfortunate. What's the least surprising behavior here? I think that since lists are un-typed, we having different return types for In [15]: integer_array([1, 2, 3]) + integer_array([1, None, 3])
Out[15]: IntegerArray([2, nan, 6], dtype='Int64')
In [16]: integer_array([1, 2, 3]) + [1, np.nan, 3]
Out[16]: array([ 2., nan, 6.]) is the most surprising. I'd be willing to have the round float case be swallowed up by integer array if necessary. So maybe the rule is "can we safely cast the right-hand side to an IntegerArray? If so, the return type is an IntegerArray" |
I think that would be fine for now (although it is different from numpy), certainly given that a list has not really dtype information. Alternatively, we could error on |
Proposal: punt. In practice we expect |
Right now,
IntegerArary.__add__
callsnp.asarray(other)
for list-like other. Whenother
is an actual list with missing values, we end up with a float ndarray.Compare with Non-NA values:
In general, an IntegerArray + ndarray[float] should be a floating point ndarray,
Do we special case missing values here?
The text was updated successfully, but these errors were encountered: