Skip to content

IntervalIndex constructor doesn't use dtype parameter #19262

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
jschendel opened this issue Jan 16, 2018 · 0 comments · Fixed by #19339
Closed

IntervalIndex constructor doesn't use dtype parameter #19262

jschendel opened this issue Jan 16, 2018 · 0 comments · Fixed by #19339
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Interval Interval data type
Milestone

Comments

@jschendel
Copy link
Member

Code Sample, a copy-pastable example if possible

The IntervalIndex constructor takes a dtype parameter but doesn't use it (no references to it in the code):

In [2]:  pd.IntervalIndex([pd.Interval(0, 1), pd.Interval(2, 3)], dtype='float64')
Out[2]:
IntervalIndex([(0, 1], (2, 3]]
              closed='right',
              dtype='interval[int64]')

The constructor methods do not support a dtype parameter:

In [3]: pd.IntervalIndex.from_intervals([pd.Interval(0, 1), pd.Interval(2, 3)], dtype='float64')
---------------------------------------------------------------------------
TypeError: from_intervals() got an unexpected keyword argument 'dtype'

In [4]: pd.IntervalIndex.from_arrays([0, 2], [1, 3], dtype='float64')
---------------------------------------------------------------------------
TypeError: from_arrays() got an unexpected keyword argument 'dtype'

In [5]: pd.IntervalIndex.from_breaks([0, 1, 2, 3], dtype='float64')
---------------------------------------------------------------------------
TypeError: from_breaks() got an unexpected keyword argument 'dtype'

In [6]: pd.IntervalIndex.from_tuples([(0, 1), (2, 3)], dtype='float64')
---------------------------------------------------------------------------
TypeError: from_tuples() got an unexpected keyword argument 'dtype'

Expected Output

I'd expect the IntervalIndex constructor and constructor methods to support a dtype parameter, which can be used to override the inferred dtype.

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Interval Interval data type Difficulty Intermediate API Design labels Jan 16, 2018
@jreback jreback added this to the Next Major Release milestone Jan 16, 2018
@jreback jreback modified the milestones: Next Major Release, 0.23.0 Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Interval Interval data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants