pandas.IntervalIndex.set_closed#

IntervalIndex.set_closed(closed)[source]#

Return an identical IntervalIndex closed on the specified side.

This method creates a new IntervalIndex with the same bounds but with a different closure specification.

Parameters:
closed{‘left’, ‘right’, ‘both’, ‘neither’}

Whether the intervals are closed on the left-side, right-side, both or neither.

Returns:
IntervalIndex

A new IntervalIndex with the specified side closures.

See also

IntervalIndex.closed

Returns inclusive side of the IntervalIndex.

Examples

>>> index = pd.interval_range(0, 3)
>>> index
IntervalIndex([(0, 1], (1, 2], (2, 3]],
              dtype='interval[int64, right]')
>>> index.set_closed("both")
IntervalIndex([[0, 1], [1, 2], [2, 3]],
              dtype='interval[int64, both]')