Skip to content

BUG: NumericIndex.insert does not preserve dtype #43921

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

Closed
3 tasks done
jbrockmendel opened this issue Oct 8, 2021 · 0 comments · Fixed by #43933
Closed
3 tasks done

BUG: NumericIndex.insert does not preserve dtype #43921

jbrockmendel opened this issue Oct 8, 2021 · 0 comments · Fixed by #43933
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses
Milestone

Comments

@jbrockmendel
Copy link
Member

  • 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 master branch of pandas.

Reproducible Example

import pandas as pd

idx = pd.NumericIndex([1.0, 2.0, 3.0] dtype='int32')
result = idx.insert(1, 4.0)

assert result.dtype == idx.dtype  # <- nope!


### Issue Description

cc @topper-123 

### Expected Behavior

Should preserve type and dtype

### Installed Versions

<details>

Replace this line with the output of pd.show_versions()

</details>
@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 8, 2021
@jreback jreback added this to the 1.4 milestone Oct 9, 2021
@jreback jreback 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 Oct 9, 2021
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