The parameters :None:None:`left`
and :None:None:`right`
must be from the same type, you must be able to compare them and they must satisfy left <= right
.
A closed interval (in mathematics denoted by square brackets) contains its endpoints, i.e. the closed interval [0, 5]
is characterized by the conditions 0 <= x <= 5
. This is what closed='both'
stands for. An open interval (in mathematics denoted by parentheses) does not contain its endpoints, i.e. the open interval (0, 5)
is characterized by the conditions 0 < x < 5
. This is what closed='neither'
stands for. Intervals can also be half-open or half-closed, i.e. [0, 5)
is described by 0 <= x < 5
( closed='left'
) and (0, 5]
is described by 0 < x <= 5
( closed='right'
).
Left bound for the interval.
Right bound for the interval.
Whether the interval is closed on the left-side, right-side, both or neither. See the Notes for more detailed explanation.
Immutable object implementing an Interval, a bounded slice-like interval.
IntervalIndex
An Index of Interval objects that are all closed on the same side.
Period
Represents a period of time.
cut
Convert continuous data into discrete bins (Categorical of Interval objects).
qcut
Convert continuous data into bins (Categorical of Interval objects) based on quantiles.
It is possible to build Intervals of different types, like numeric ones:
This example is valid syntax, but we were not able to check execution>>> iv = pd.Interval(left=0, right=5)
... iv Interval(0, 5, closed='right')
You can check if an element belongs to it
This example is valid syntax, but we were not able to check execution>>> 2.5 in iv True
You can test the bounds ( closed='right'
, so 0 < x <= 5
):
>>> 0 in iv FalseThis example is valid syntax, but we were not able to check execution
>>> 5 in iv TrueThis example is valid syntax, but we were not able to check execution
>>> 0.0001 in iv True
Calculate its length
This example is valid syntax, but we were not able to check execution>>> iv.length 5
You can operate with :None:None:`+`
and :None:None:`*`
over an Interval and the operation is applied to each of its bounds, so the result depends on the type of the bound elements
>>> shifted_iv = iv + 3This example is valid syntax, but we were not able to check execution
... shifted_iv Interval(3, 8, closed='right')
>>> extended_iv = iv * 10.0
... extended_iv Interval(0.0, 50.0, closed='right')
To create a time interval you can use Timestamps as the bounds
This example is valid syntax, but we were not able to check execution>>> year_2017 = pd.Interval(pd.Timestamp('2017-01-01 00:00:00'),This example is valid syntax, but we were not able to check execution
... pd.Timestamp('2018-01-01 00:00:00'),
... closed='left')
... pd.Timestamp('2017-01-01 00:00') in year_2017 True
>>> year_2017.length Timedelta('365 days 00:00:00')See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.arrays.interval.IntervalArray
pandas.core.indexes.interval.IntervalIndex
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them