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
IntervalIndex constructor ignores closed parameter for purely NA data:
In [3]: pd.IntervalIndex([np.nan], closed='both')
Out[3]:
IntervalIndex([nan]
closed='right',
dtype='interval[float64]')
In [4]: pd.IntervalIndex([np.nan, np.nan], closed='neither')
Out[4]:
IntervalIndex([nan, nan]
closed='right',
dtype='interval[float64]')
This only occurs on master, as it appears to be an over-correction resulting from the fix in #18340
IntervalIndex also ignores closed when it conflicts with the how the input data is closed:
In [6]: ivs= [pd.Interval(0, 1, closed='both'), pd.Interval(10, 20, closed='both')]
In [7]: pd.IntervalIndex(ivs, closed='neither')
Out[7]:
IntervalIndex([[0, 1], [10, 20]]
closed='both',
dtype='interval[int64]')
The behavior above occurs on master, and is a result of #18340. The opposite behavior occurred prior, where intervals would always be coerced to match the closed specified by the constructor. Should probably raise when the constructor vs. inferred closed conflict.
Inconsistent dtype for empty IntervalIndex depending on the method of construction:
In [2]: pd.IntervalIndex([]).dtypeOut[2]: interval[object]
In [3]: pd.IntervalIndex.from_intervals([]).dtypeOut[3]: interval[object]
In [4]: pd.IntervalIndex.from_breaks([]).dtypeOut[4]: interval[float64]
In [5]: pd.IntervalIndex.from_tuples([]).dtypeOut[5]: interval[float64]
In [6]: pd.IntervalIndex.from_arrays([], []).dtypeOut[6]: interval[float64]
Expected Output
IntervalIndex constructor should not ignore the closed parameter for purely NA data (since it can't infer closed from the input data).
IntervalIndex should raise when given conflicting closed vs. inferred closed from data.
IntervalIndex should have the same dtype for empty data regardless of the method of construction. It's not immediately clear to me which dtype should be used, but my feeling is interval[object] since that's the behavior of the constructor/from_intervals.
The text was updated successfully, but these errors were encountered:
Code Sample, a copy-pastable example if possible
IntervalIndex
constructor ignoresclosed
parameter for purely NA data:This only occurs on master, as it appears to be an over-correction resulting from the fix in #18340
IntervalIndex
also ignoresclosed
when it conflicts with the how the input data is closed:The behavior above occurs on master, and is a result of #18340. The opposite behavior occurred prior, where intervals would always be coerced to match the
closed
specified by the constructor. Should probably raise when the constructor vs. inferredclosed
conflict.IntervalIndex
depending on the method of construction:Expected Output
IntervalIndex
constructor should not ignore theclosed
parameter for purely NA data (since it can't inferclosed
from the input data).IntervalIndex
should raise when given conflictingclosed
vs. inferredclosed
from data.IntervalIndex
should have the same dtype for empty data regardless of the method of construction. It's not immediately clear to me which dtype should be used, but my feeling isinterval[object]
since that's the behavior of the constructor/from_intervals
.The text was updated successfully, but these errors were encountered: