pandas.IntervalIndex.contains#

IntervalIndex.contains(other)[source]#

Check elementwise if the Intervals contain the value.

Return a boolean mask whether the value is contained in the Intervals of the IntervalIndex.

Parameters:
otherscalar

The value to check whether it is contained in the Intervals.

Returns:
numpy.ndarray[bool]

A boolean mask whether the value is contained in the Intervals.

See also

IntervalIndex.__contains__

Check whether an Interval is one of the IntervalIndex’s elements.

IntervalIndex.overlaps

Check if an Interval overlaps the values in the IntervalIndex.

Examples

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