pandas / 0.25.0 / reference / api / pandas.intervalindex.contains.html /

pandas.IntervalIndex.contains

IntervalIndex.contains(self, 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.

New in version 0.25.0.

Parameters:
other : scalar

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

Returns:
boolean array

See also

Interval.contains
Check whether Interval object contains value.
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]],
      closed='right',
      dtype='interval[int64]')
>>> intervals.contains(0.5)
array([ True, False, 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.contains.html