Skip to content
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

API: Index.insert too much dtype inference #51363

Closed
jbrockmendel opened this issue Feb 13, 2023 · 0 comments · Fixed by #55257
Closed

API: Index.insert too much dtype inference #51363

jbrockmendel opened this issue Feb 13, 2023 · 0 comments · Fixed by #55257
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Feb 13, 2023

idx = pd.Index([1], dtype=object)

idx.insert(0, 1).dtype

ATM Index.insert uses Index._with_infer to construct a result, which will cast the case here to int64 instead of retaining object. I think in this case it would be more reasonable to keep object dtype, which we'd get by just calling Index.__new__ instead of _with_infer.

We have no tests that depend on this ATM.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 13, 2023
@phofl phofl added Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants