Skip to content

BUG: Index constructor does not maintain CategoricalDtype #19048

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

Merged
merged 1 commit into from
Jan 3, 2018

Conversation

jschendel
Copy link
Member

from .interval import IntervalIndex
return IntervalIndex.from_intervals(data, name=name,
copy=copy)
return IntervalIndex(data, dtype=dtype, name=name, copy=copy)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IntervalIndex changes are more about future proofing; the dtype kwarg currently doesn't do anything for IntervalIndex, so there aren't really any tests that can be added. I plan to create a PR to allow conversion between subtypes and initializing with non-inferred subtype (e.g. interval[int64] to interval[float64]) where I believe the same issue will come into play, so figured I'd put this code in place now while it's fresh on my mind.

Also, switched from IntervalIndex.from_intervals to the IntervalIndex constructor since the constructor does everything from_intervals does, but has more features and better testing. Would eventually like to either remove from_intervals or just redirect it to the constructor.

@codecov
Copy link

codecov bot commented Jan 3, 2018

Codecov Report

Merging #19048 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19048      +/-   ##
==========================================
- Coverage   91.57%   91.56%   -0.01%     
==========================================
  Files         150      150              
  Lines       48942    48942              
==========================================
- Hits        44818    44816       -2     
- Misses       4124     4126       +2
Flag Coverage Δ
#multiple 89.93% <100%> (-0.01%) ⬇️
#single 41.75% <66.66%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.45% <100%> (ø) ⬆️
pandas/util/testing.py 84.74% <0%> (-0.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab000a9...4080bc0. Read the comment docs.

@jreback jreback added Bug Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions Interval Interval data type labels Jan 3, 2018
@jreback jreback added this to the 0.23.0 milestone Jan 3, 2018
@jreback jreback merged commit e459133 into pandas-dev:master Jan 3, 2018
@jreback
Copy link
Contributor

jreback commented Jan 3, 2018

thanks!

@jschendel jschendel deleted the idx-cat-dtype branch January 3, 2018 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Index(data=..., dtype=CategoricalDtype(...)) doesn't maintain dtype
2 participants