When creating an IntervalArray in Pandas with values such as pd.Interval(0, 1) and pd.Interval(1, 5), the output is displayed as [(0, 1], (1, 5]]. Why does each interval use a parenthesis on the left and a square bracket on the right, and what do those symbols mean?
3 Answers
This is standard mathematical interval notation. A parenthesis means the endpoint is excluded, while a square bracket means it is included. Therefore, (0, 1] means values greater than 0 and less than or equal to 1.
Intervals let Pandas represent ranges and test membership without expanding every possible value. Instead of storing ranges as strings and manually parsing their endpoints, an IntervalArray can directly determine whether a value belongs to a particular interval.
Pandas commonly uses right-closed intervals so adjacent bins don't overlap. For example, (0, 10] and (10, 20] give each boundary value a single bin. This is especially useful with functions such as pd.cut and pd.qcut, where values are assigned to ranges.

That makes sense—thanks for explaining it clearly. I hadn't encountered this notation before.