You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling searchsorted on an int haystack with str needle converts haystack to str #6061
The main reason why I believe this behavior is broken is because when one converts an integer array to strings, it's not sorted anymore.
I believe that the least surprising result would be an exception, especially because this is what happens if the array contains floats and not integers.
P.S. I initially asked about this on StackOverflow, and @jaimefrio suggested creating a bug report in the comments.
I think fixing this boils down to whether it is a searchsorted bug, and we need to put a special check there, or it really is a can_cast bug, and we should disallow safe casting of ints to strings, as we already do for floats.
+1 to making int->str considered not-safe. Generally "safe" for us means
"should be implicitly coerceable", and python in general does not allow
implicit coercion of int->str, so this seems pretty correct to me.
On Jul 10, 2015 12:33 PM, "Jaime" [email protected] wrote:
I think fixing this boils down to whether it is a searchsorted bug, and
we need to put a special check there, or it really is a can_cast bug, and
we should disallow safe casting of ints to strings, as we already do for
floats.
—
Reply to this email directly or view it on GitHub #6061 (comment).
Activity
jaimefrio commentedon Jul 10, 2015
I think fixing this boils down to whether it is a
searchsortedbug, and we need to put a special check there, or it really is acan_castbug, and we should disallow safe casting of ints to strings, as we already do for floats.njsmith commentedon Jul 10, 2015
+1 to making int->str considered not-safe. Generally "safe" for us means
"should be implicitly coerceable", and python in general does not allow
implicit coercion of int->str, so this seems pretty correct to me.
On Jul 10, 2015 12:33 PM, "Jaime" [email protected] wrote:
BUG: It should not be safe to cast from int to string.
OmerJog commentedon May 23, 2019
Is there a fix for this?