IntervalIndex constructor doesn't use dtype parameter · Issue #19262 · pandas-dev/pandas (original) (raw)
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.