pandas.IntervalIndex

class pandas.IntervalIndex[source]

Immutable Index implementing an ordered, sliceable set. IntervalIndex represents an Index of Interval objects that are all closed on the same side.

New in version 0.20.0.

Warning

The indexing behaviors are provisional and may change in a future version of pandas.

See also

Index
The base pandas Index type
Interval
A bounded slice-like interval; the elements of an IntervalIndex
interval_range
Function to create a fixed frequency IntervalIndex

cut, qcut

Notes

See the user guide for more.

Examples

A new IntervalIndex is typically constructed using interval_range():

>>> pd.interval_range(start=0, end=5)
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]]
              closed='right', dtype='interval[int64]')

It may also be constructed using one of the constructor methods: IntervalIndex.from_arrays(), IntervalIndex.from_breaks(), IntervalIndex.from_intervals() and IntervalIndex.from_tuples().

See further examples in the doc strings of interval_range and the mentioned constructor methods.

Attributes

left,
closed Whether the intervals are closed on the left-side, right-side, both or
name
copy([deep, name]) Make a copy of this object.
mid
values
is_non_overlapping_monotonic

Methods

from_arrays(left, right[, closed, name, copy]) Construct an IntervalIndex from a a left and right array
from_tuples(data[, closed, name, copy]) Construct an IntervalIndex from a list/array of tuples
from_breaks(breaks[, closed, name, copy]) Construct an IntervalIndex from an array of splits
from_intervals(data[, name, copy]) Construct an IntervalIndex from a 1d array of Interval objects
contains(key) Return a boolean indicating if the key is IN the index
Scroll To Top