Closed
Description
An is_empty
attribute would be useful, as it is often necessary to special case empty intervals when dealing with Interval
methods such as overlaps
, contains
, etc. (xref #26893)
For a scalar Interval
this should return a boolean:
In [2]: pd.Interval(0, 0, closed='neither').is_empty
Out[2]: True
In [3]: pd.Interval(0, 1, closed='neither').is_empty
Out[3]: False
For an IntervalIndex
or IntervalArray
this should return a boolean ndarray positionally indicating if a given Interval
is empty:
In [4]: pd.IntervalIndex.from_tuples([(0, 0), (0, 1)]).is_empty
Out[4]: array([ True, False])