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

ENH: Index Pandas Dtype #43857

Closed
ghost opened this issue Oct 3, 2021 · 1 comment
Closed

ENH: Index Pandas Dtype #43857

ghost opened this issue Oct 3, 2021 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses

Comments

@ghost
Copy link

ghost commented Oct 3, 2021

Hello,

Is it possible to set pandas dtype-like to index.dtype

Pandas Dtypes Examples

pandas.Int64Dtype(), pandas.Int8Dtype()

Expected result

df.index = pd.Series(df['X'].astype('Int64'))

Index([1, 2, 3, 4, 5], dtype='Int64', name='X')
# instead of
Index([1, 2, 3, 4, 5], dtype='object', name='X')

Workaround
Im forcing change in dtype convertion (it expects to have not nullable values)

INDEX_TYPE_MAP = {
    pandas.Int8Dtype(): numpy.int8,
    pandas.Int16Dtype(): numpy.int16,
    pandas.Int32Dtype(): numpy.int32,
    pandas.Int64Dtype(): numpy.int64,
    pandas.Float32Dtype(): numpy.float32,
    pandas.Float64Dtype(): numpy.float64
}

Br
Nicolas

@ghost ghost added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 3, 2021
@ghost ghost mentioned this issue Oct 3, 2021
4 tasks
@debnathshoham
Copy link
Member

see #39133

@debnathshoham debnathshoham added Duplicate Report Duplicate issue or pull request ExtensionArray Extending pandas with custom dtypes or arrays. 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 3, 2021
@phofl phofl closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

2 participants