Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.IntervalIndex.set_closed

IntervalIndex.set_closed(closed)[source]

Return an IntervalIndex identical to the current one, but closed on the specified side

New in version 0.24.0.

Parameters:

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

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

Returns:
new_index : IntervalIndex

Examples

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