W3cubDocs

/pandas 0.25

pandas.IntervalIndex.overlaps

IntervalIndex.overlaps(self, other) [source]

Check elementwise if an Interval overlaps the values in the IntervalIndex.

Two intervals overlap if they share a common point, including closed endpoints. Intervals that only have an open endpoint in common do not overlap.

New in version 0.24.0.

Parameters:
other : Interval

Interval to check against for an overlap.

Returns:
ndarray

Boolean array positionally indicating where an overlap occurs.

See also

Interval.overlaps
Check whether two Interval objects overlap.

Examples

>>> intervals = pd.IntervalIndex.from_tuples([(0, 1), (1, 3), (2, 4)])
>>> intervals
IntervalIndex([(0, 1], (1, 3], (2, 4]],
      closed='right',
      dtype='interval[int64]')
>>> intervals.overlaps(pd.Interval(0.5, 1.5))
array([ True,  True, False])

Intervals that share closed endpoints overlap:

>>> intervals.overlaps(pd.Interval(1, 3, closed='left'))
array([ True,  True, True])

Intervals that only have an open endpoint in common do not overlap:

>>> intervals.overlaps(pd.Interval(1, 2, closed='right'))
array([False,  True, False])

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.IntervalIndex.overlaps.html