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 interval.

right : value

Right bound for interval.

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

Whether the interval is closed on the left-side, right-side, both or neither. Defaults to ‘right’.

See also

IntervalIndex
an Index of interval s that are all closed on the same side.

cut, qcut

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
closed_left
closed_right
left
mid
open_left
open_right
right
Scroll To Top