REF: IntervalIndex[IntervalArray] by TomAugspurger · Pull Request #20611 · pandas-dev/pandas (original) (raw)
There needs to be some extra checks on value
here. Right now if I pass an Interval
with a different closed
, it silently gets changed to match the array's closed
:
In [2]: ia = pd.interval_range(0, 4).insert(0, np.nan).values
In [3]: ia
Out[3]:
IntervalArray([nan, (0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]],
closed='right',
dtype='interval[float64]')
In [4]: ia.fillna(pd.Interval(10, 20, closed='both'))
Out[4]:
IntervalArray([(10.0, 20.0], (0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]],
closed='right',
dtype='interval[float64]')
Could probably create some type of helper function/method for this, as I'd guess it'd be somewhat of a common thing to do.