You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently IntervalIndex.astype doesn't do anything when passed an IntervalDtype:
In [2]: ii=pd.interval_range(0.0, 3.0)
In [3]: iiOut[3]:
IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0]]
closed='right',
dtype='interval[float64]')
In [4]: dtype=IntervalDtype('int64')
In [5]: ii.astype(dtype)
Out[5]:
IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0]]
closed='right',
dtype='interval[float64]')
This is because the current implementation of IntervalIndex.astype doesn't distinguish between different IntervalDtype, and treats them all as equivalent to the existing dtype:
Problem description
Currently
IntervalIndex.astype
doesn't do anything when passed anIntervalDtype
:This is because the current implementation of
IntervalIndex.astype
doesn't distinguish between differentIntervalDtype
, and treats them all as equivalent to the existing dtype:pandas/pandas/core/indexes/interval.py
Lines 700 to 702 in 8acdf80
Expected Output
I'd expect the subtype to be converted to
'int64'
:The text was updated successfully, but these errors were encountered: