Skip to content

[DEPR]: Remove numeric cross-kind casting in label-based lookup #53613

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
wence- opened this issue Jun 12, 2023 · 0 comments
Open

[DEPR]: Remove numeric cross-kind casting in label-based lookup #53613

wence- opened this issue Jun 12, 2023 · 0 comments
Labels
Deprecate Functionality to remove in pandas Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@wence-
Copy link
Contributor

wence- commented Jun 12, 2023

As seen in discussions in #53290, cross-kind casting cannot be made to do the "right" thing in the sense of getting out what you think you put in.

One comment from the discussion in that issue:

So this isn't a bug, but a result of indexing with big floats on integer indexes (which you shouldn't do)

I agree with this statement, and suggest that pandas should make it impossible to do this, by not supporting casting between numeric kinds in label-based lookup.

Rationale:

  • If no-one should do it anyway, then it is not a big loss if they can't.
  • It's actually very difficult to make the label lookup behave in a way that is consistent with a simple mental model, since cross-kind casting leads to value-dependent behaviour changes. Moreover, the rules as implemented are not symmetric: looking up a lossily-casted integer in a float index does not produce the same results as if one had that integer in the index and looked up with the matching float.

Other possible approaches

Maintain cross-kind casting, but at least try and tighten up the casting behaviour so that "find float in int index" and "find int in float index" behave symmetrically and self-consistently wrt passing array-like or scalar-like arguments (this was the original reason for reporting #53290).

@lithomas1 lithomas1 added Indexing Related to indexing on series/frames, not to indexes themselves Dtype Conversions Unexpected or buggy dtype conversions Deprecate Functionality to remove in pandas labels Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

No branches or pull requests

2 participants