# pandas.Interval¶

class pandas.Interval

Immutable object implementing an Interval, a bounded slice-like interval.

New in version 0.20.0.

Parameters: left : value Left bound for the interval right : value Right bound for the interval closed : {‘left’, ‘right’, ‘both’, ‘neither’}, default ‘right’ Whether the interval is closed on the left-side, right-side, both or neither

IntervalIndex
An Index of Interval objects that are all closed on the same side.

Examples

>>> iv = pd.Interval(left=0, right=5)
>>> iv
Interval(0, 5, closed='right')
>>> 2.5 in iv
True

>>> year_2017 = pd.Interval(pd.Timestamp('2017-01-01'),
...                         pd.Timestamp('2017-12-31'), closed='both')
>>> pd.Timestamp('2017-01-01 00:00') in year_2017
True


Attributes

 closed Whether the interval is closed on the left-side, right-side, both or closed_left Return True if the Interval is closed on the left-side, else False closed_right Return True if the Interval is closed on the right-side, else False left Left bound for the interval length Return the length of the Interval mid Return the midpoint of the Interval open_left Return True if the Interval is open on the left-side, else False open_right Return True if the Interval is open on the right-side, else False right Right bound for the interval
Scroll To Top